"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer2/CoordSet.cpp" between
pymol-v2.1.0.tar.bz2 and pymol-open-source-2.2.0.tar.gz

About: PyMOL is a Python-enhanced molecular graphics tool. It excels at 3D visualization of proteins, small molecules, density, surfaces, and trajectories. It also includes molecular editing, ray tracing, and movies. Open Source version.

CoordSet.cpp  (pymol-v2.1.0.tar.bz2):CoordSet.cpp  (pymol-open-source-2.2.0)
skipping to change at line 42 skipping to change at line 42
#include"P.h" #include"P.h"
#include"Matrix.h" #include"Matrix.h"
#include"Sphere.h" #include"Sphere.h"
#include"Util.h" #include"Util.h"
#include"Feedback.h" #include"Feedback.h"
#include"RepWireBond.h" #include"RepWireBond.h"
#include"RepCylBond.h" #include"RepCylBond.h"
#include"RepDot.h" #include"RepDot.h"
#include"RepMesh.h" #include"RepMesh.h"
#include"RepSphere.h" #include"RepSphere.h"
#include"RepSphereImmediate.h"
#include"RepRibbon.h" #include"RepRibbon.h"
#include"RepCartoon.h" #include"RepCartoon.h"
#include"RepSurface.h" #include"RepSurface.h"
#include"RepLabel.h" #include"RepLabel.h"
#include"RepNonbonded.h" #include"RepNonbonded.h"
#include"RepNonbondedSphere.h" #include"RepNonbondedSphere.h"
#include"RepEllipsoid.h" #include"RepEllipsoid.h"
#include"PyMOLGlobals.h" #include"PyMOLGlobals.h"
#include"PyMOLObject.h" #include"PyMOLObject.h"
#ifdef _PYMOL_IP_EXTRAS
#endif
#include "Executive.h" #include "Executive.h"
#include "Lex.h" #include "Lex.h"
#ifdef _PYMOL_IP_PROPERTIES
#include "Property.h"
#endif
/*========================================================================*/ /*========================================================================*/
/* /*
* Get coordinate index for given atom index * Get coordinate index for given atom index
*/ */
int CoordSet::atmToIdx(int atm) const { int CoordSet::atmToIdx(int atm) const {
if (Obj->DiscreteFlag) { if (Obj->DiscreteFlag) {
if (this == Obj->DiscreteCSet[atm]) if (this == Obj->DiscreteCSet[atm])
return Obj->DiscreteAtmToIdx[atm]; return Obj->DiscreteAtmToIdx[atm];
return -1; return -1;
} }
skipping to change at line 164 skipping to change at line 167
if(ok) if(ok)
ok = PConvPyListToIntVLA(PyList_GetItem(list, 3), &I->IdxToAtm); ok = PConvPyListToIntVLA(PyList_GetItem(list, 3), &I->IdxToAtm);
if(ok && (ll > 5)) if(ok && (ll > 5))
ok = PConvPyStrToStr(PyList_GetItem(list, 5), I->Name, sizeof(WordType)); ok = PConvPyStrToStr(PyList_GetItem(list, 5), I->Name, sizeof(WordType));
if(ok && (ll > 6)) if(ok && (ll > 6))
ok = ObjectStateFromPyList(G, PyList_GetItem(list, 6), &I->State); ok = ObjectStateFromPyList(G, PyList_GetItem(list, 6), &I->State);
if(ok && (ll > 7)) if(ok && (ll > 7))
I->Setting = SettingNewFromPyList(G, PyList_GetItem(list, 7)); I->Setting = SettingNewFromPyList(G, PyList_GetItem(list, 7));
if(ok && (ll > 8)) if(ok && (ll > 8))
ok = PConvPyListToLabPosVLA(PyList_GetItem(list, 8), &I->LabPos); ok = PConvPyListToLabPosVLA(PyList_GetItem(list, 8), &I->LabPos);
#ifdef _PYMOL_IP_PROPERTIES
#endif
if(ok && (ll > 10)){
CPythonVal *val = CPythonVal_PyList_GetItem(G, list, 10);
if (!CPythonVal_IsNone(val))
I->SculptCGO = CGONewFromPyList(G, val, 0, 1);
else {
I->SculptShaderCGO = I->SculptCGO = NULL;
}
CPythonVal_Free(val);
}
if(ok){
if(ll > 11){
// load in atom-state settings
CPythonVal *val = CPythonVal_PyList_GetItem(G, list, 11);
if (!CPythonVal_IsNone(val)){
int a;
I->atom_state_setting_id = VLACalloc(int, I->NIndex);
I->has_atom_state_settings = VLACalloc(char, I->NIndex);
for (a=0; a<I->NIndex; a++){
CPythonVal *val2 = CPythonVal_PyList_GetItem(G, val, a);
if (!CPythonVal_IsNone(val2)){
CPythonVal_PConvPyIntToInt(val2, &I->atom_state_setting_id[a]);
I->has_atom_state_settings[a] = (I->atom_state_setting_id[a]) ? 1 :
0;
if (I->atom_state_setting_id[a]) {
I->atom_state_setting_id[a] = SettingUniqueConvertOldSessionID(G,
I->atom_state_setting_id[a]);
}
}
CPythonVal_Free(val2);
}
} else {
I->atom_state_setting_id = NULL;
I->has_atom_state_settings = NULL;
}
CPythonVal_Free(val);
} else {
// check I->LabPos.offset to see if its set
if (I->LabPos){
int a;
for (a=0; a<I->NIndex; a++){
if(length3f(I->LabPos[a].offset) > R_SMALL4) {
SettingSet(cSetting_label_placement_offset, I->LabPos[a].offset, I,
a);
}
}
}
}
}
if(!ok) { if(!ok) {
if(I) if(I)
I->fFree(); I->fFree();
*cs = NULL; *cs = NULL;
} else { } else {
*cs = I; *cs = I;
} }
} }
return (ok); return (ok);
} }
skipping to change at line 223 skipping to change at line 275
#endif #endif
} }
PyObject *CoordSetAsPyList(CoordSet * I) PyObject *CoordSetAsPyList(CoordSet * I)
{ {
PyObject *result = NULL; PyObject *result = NULL;
if(I) { if(I) {
int pse_export_version = SettingGetGlobal_f(I->State.G, cSetting_pse_export_ version) * 1000; int pse_export_version = SettingGetGlobal_f(I->State.G, cSetting_pse_export_ version) * 1000;
bool dump_binary = SettingGetGlobal_b(I->State.G, cSetting_pse_binary_dump) && (!pse_export_version || pse_export_version >= 1765); bool dump_binary = SettingGetGlobal_b(I->State.G, cSetting_pse_binary_dump) && (!pse_export_version || pse_export_version >= 1765);
result = PyList_New(9); result = PyList_New(12);
PyList_SetItem(result, 0, PyInt_FromLong(I->NIndex)); PyList_SetItem(result, 0, PyInt_FromLong(I->NIndex));
PyList_SetItem(result, 1, PyInt_FromLong(I->NAtIndex)); PyList_SetItem(result, 1, PyInt_FromLong(I->NAtIndex));
PyList_SetItem(result, 2, PConvFloatArrayToPyList(I->Coord, I->NIndex * 3, d ump_binary)); PyList_SetItem(result, 2, PConvFloatArrayToPyList(I->Coord, I->NIndex * 3, d ump_binary));
PyList_SetItem(result, 3, PConvIntArrayToPyList(I->IdxToAtm, I->NIndex, dump _binary)); PyList_SetItem(result, 3, PConvIntArrayToPyList(I->IdxToAtm, I->NIndex, dump _binary));
if(I->AtmToIdx if(I->AtmToIdx
&& pse_export_version < 1770) && pse_export_version < 1770)
PyList_SetItem(result, 4, PConvIntArrayToPyList(I->AtmToIdx, I->NAtIndex, dump_binary)); PyList_SetItem(result, 4, PConvIntArrayToPyList(I->AtmToIdx, I->NAtIndex, dump_binary));
else else
PyList_SetItem(result, 4, PConvAutoNone(NULL)); PyList_SetItem(result, 4, PConvAutoNone(NULL));
PyList_SetItem(result, 5, PyString_FromString(I->Name)); PyList_SetItem(result, 5, PyString_FromString(I->Name));
PyList_SetItem(result, 6, ObjectStateAsPyList(&I->State)); PyList_SetItem(result, 6, ObjectStateAsPyList(&I->State));
PyList_SetItem(result, 7, SettingAsPyList(I->Setting)); PyList_SetItem(result, 7, SettingAsPyList(I->Setting));
PyList_SetItem(result, 8, PConvLabPosVLAToPyList(I->LabPos, I->NIndex)); PyList_SetItem(result, 8, PConvLabPosVLAToPyList(I->LabPos, I->NIndex));
PyList_SetItem(result, 9,
#ifdef _PYMOL_IP_PROPERTIES
#endif
PConvAutoNone(Py_None));
if(I->SculptCGO) {
PyList_SetItem(result, 10, CGOAsPyList(I->SculptCGO));
} else {
PyList_SetItem(result, 10, PConvAutoNone(NULL));
}
if (I->has_atom_state_settings){
int a;
PyObject *settings_list = NULL;
settings_list = PyList_New(I->NIndex);
for (a=0; a<I->NIndex; a++){
if (I->has_atom_state_settings[a]){
PyList_SetItem(settings_list, a, PyInt_FromLong(I->atom_state_setting_i
d[a]));
} else {
PyList_SetItem(settings_list, a, PConvAutoNone(NULL));
}
}
PyList_SetItem(result, 11, settings_list);
} else {
PyList_SetItem(result, 11, PConvAutoNone(NULL));
}
/* TODO symmetry, spheroid, periodic box ... */ /* TODO symmetry, spheroid, periodic box ... */
} }
return (PConvAutoNone(result)); return (PConvAutoNone(result));
} }
void CoordSetAdjustAtmIdx(CoordSet * I, int *lookup, int nAtom) void CoordSetAdjustAtmIdx(CoordSet * I, int *lookup, int nAtom)
/* performs second half of removal */ /* performs second half of removal */
{ {
/* NOTE: only works in a compressive mode, where lookup[a]<=a */ /* NOTE: only works in a compressive mode, where lookup[a]<=a */
int a; int a, a0, atm;
int a0; char *new_has_atom_state_settings_by_atom = NULL;
int *new_atom_state_setting_id_by_atom = NULL;
int nIndex = I->NIndex;
PRINTFD(I->State.G, FB_CoordSet) PRINTFD(I->State.G, FB_CoordSet)
" CoordSetAdjustAtmIdx-Debug: entered NAtIndex: %d NIndex %d\n I->AtmToIdx % p\n", " CoordSetAdjustAtmIdx-Debug: entered NAtIndex: %d NIndex %d\n I->AtmToIdx % p\n",
I->NAtIndex, I->NIndex, (void *) I->AtmToIdx ENDFD; I->NAtIndex, I->NIndex, (void *) I->AtmToIdx ENDFD;
if (I->has_atom_state_settings){
new_has_atom_state_settings_by_atom = VLACalloc(char, nIndex);
new_atom_state_setting_id_by_atom = VLACalloc(int, nIndex);
}
for(a = 0; a < nIndex; a++) {
atm = I->IdxToAtm[a];
a0 = lookup[atm];
if (a0 < 0){
if (I->has_atom_state_settings){
if (I->has_atom_state_settings[a]){
SettingUniqueDetachChain(I->State.G, I->atom_state_setting_id[a]);
I->has_atom_state_settings[a] = 0;
I->atom_state_setting_id[a] = 0;
}
}
} else if (new_has_atom_state_settings_by_atom){
new_has_atom_state_settings_by_atom[a0] = I->has_atom_state_settings[a];
new_atom_state_setting_id_by_atom[a0] = I->atom_state_setting_id[a];
}
}
if (I->AtmToIdx){ if (I->AtmToIdx){
for(a = 0; a < I->NAtIndex; a++) { for(a = 0; a < I->NAtIndex; a++) {
a0 = lookup[a]; a0 = lookup[a];
if(a0 >= 0) { if(a0 >= 0) {
I->AtmToIdx[a0] = I->AtmToIdx[a]; I->AtmToIdx[a0] = I->AtmToIdx[a];
} }
} }
} }
I->NAtIndex = nAtom; I->NAtIndex = nAtom;
if (I->AtmToIdx){ if (I->AtmToIdx){
VLASize(I->AtmToIdx, int, nAtom); VLASize(I->AtmToIdx, int, nAtom);
} }
for(a = 0; a < I->NIndex; a++) { for(a = 0; a < I->NIndex; a++) {
I->IdxToAtm[a] = lookup[I->IdxToAtm[a]]; atm = I->IdxToAtm[a] = lookup[I->IdxToAtm[a]];
if (new_has_atom_state_settings_by_atom){
I->has_atom_state_settings[a] = new_has_atom_state_settings_by_atom[atm];
I->atom_state_setting_id[a] = new_atom_state_setting_id_by_atom[atm];
}
}
if (new_has_atom_state_settings_by_atom){
VLAFreeP(new_has_atom_state_settings_by_atom);
VLAFreeP(new_atom_state_setting_id_by_atom);
} }
PRINTFD(I->State.G, FB_CoordSet) PRINTFD(I->State.G, FB_CoordSet)
" CoordSetAdjustAtmIdx-Debug: leaving... NAtIndex: %d NIndex %d\n", " CoordSetAdjustAtmIdx-Debug: leaving... NAtIndex: %d NIndex %d\n",
I->NAtIndex, I->NIndex ENDFD; I->NAtIndex, I->NIndex ENDFD;
} }
/*========================================================================*/ /*========================================================================*/
int CoordSetMerge(ObjectMolecule *OM, CoordSet * I, CoordSet * cs) int CoordSetMerge(ObjectMolecule *OM, CoordSet * I, CoordSet * cs)
{ /* must be non-overlapping */ { /* must be non-overlapping */
skipping to change at line 346 skipping to change at line 455
/* performs first half of removal */ /* performs first half of removal */
{ {
int offset = 0; int offset = 0;
int a, a1, ao; int a, a1, ao;
AtomInfoType *ai; AtomInfoType *ai;
ObjectMolecule *obj; ObjectMolecule *obj;
float *c0, *c1; float *c0, *c1;
LabPosType *l0, *l1; LabPosType *l0, *l1;
RefPosType *r0, *r1; RefPosType *r0, *r1;
int *atom_state0, *atom_state1;
char *has_atom_state0, *has_atom_state1;
obj = I->Obj; obj = I->Obj;
PRINTFD(I->State.G, FB_CoordSet) PRINTFD(I->State.G, FB_CoordSet)
" CoordSetPurge-Debug: entering..." ENDFD; " CoordSetPurge-Debug: entering..." ENDFD;
c0 = c1 = I->Coord; c0 = c1 = I->Coord;
r0 = r1 = I->RefPos; r0 = r1 = I->RefPos;
l0 = l1 = I->LabPos; l0 = l1 = I->LabPos;
atom_state0 = atom_state1 = I->atom_state_setting_id;
has_atom_state0 = has_atom_state1 = I->has_atom_state_settings;
/* This loop slides down the atoms that are not deleted (deleteFlag) /* This loop slides down the atoms that are not deleted (deleteFlag)
it moves the Coord, RefPos, and LabPos */ it moves the Coord, RefPos, and LabPos */
for(a = 0; a < I->NIndex; a++) { for(a = 0; a < I->NIndex; a++) {
a1 = I->IdxToAtm[a]; a1 = I->IdxToAtm[a];
ai = obj->AtomInfo + a1; ai = obj->AtomInfo + a1;
if(ai->deleteFlag) { if(ai->deleteFlag) {
offset--; offset--;
c0 += 3; c0 += 3;
if(l0) if(l0)
l0++; l0++;
if(r0) if(r0)
r0++; r0++;
if (has_atom_state0){
atom_state0++;
has_atom_state0++;
}
} else if(offset) { } else if(offset) {
ao = a + offset; ao = a + offset;
*(c1++) = *(c0++); *(c1++) = *(c0++);
*(c1++) = *(c0++); *(c1++) = *(c0++);
*(c1++) = *(c0++); *(c1++) = *(c0++);
if(r1) { if(r1) {
*(r1++) = *(r0++); *(r1++) = *(r0++);
} }
if(l0) { if(l0) {
*(l1++) = *(l0++); *(l1++) = *(l0++);
} }
if (has_atom_state0){
*(atom_state1++) = *(atom_state0++);
*(has_atom_state1++) = *(has_atom_state0++);
}
if (I->AtmToIdx) if (I->AtmToIdx)
I->AtmToIdx[a1] = ao; I->AtmToIdx[a1] = ao;
I->IdxToAtm[ao] = a1; /* no adjustment of these indexes yet... */ I->IdxToAtm[ao] = a1; /* no adjustment of these indexes yet... */
if (I->Obj->DiscreteFlag){ if (I->Obj->DiscreteFlag){
I->Obj->DiscreteAtmToIdx[a1] = ao; I->Obj->DiscreteAtmToIdx[a1] = ao;
I->Obj->DiscreteCSet[a1] = I; I->Obj->DiscreteCSet[a1] = I;
} }
} else { } else {
c0 += 3; c0 += 3;
c1 += 3; c1 += 3;
if(r1) { if(r1) {
r0++; r0++;
r1++; r1++;
} }
if(l0) { if(l0) {
l0++; l0++;
l1++; l1++;
} }
if (has_atom_state0){
atom_state0++; atom_state1++;
has_atom_state0++; has_atom_state1++;
}
} }
} }
if(offset) { if(offset) {
/* If there were deleted atoms, (offset < 0), then /* If there were deleted atoms, (offset < 0), then
re-adjust the array sizes */ re-adjust the array sizes */
I->NIndex += offset; I->NIndex += offset;
VLASize(I->Coord, float, I->NIndex * 3); VLASize(I->Coord, float, I->NIndex * 3);
if(I->LabPos) { if(I->LabPos) {
VLASize(I->LabPos, LabPosType, I->NIndex); VLASize(I->LabPos, LabPosType, I->NIndex);
} }
if(I->RefPos) { if(I->RefPos) {
VLASize(I->RefPos, RefPosType, I->NIndex); VLASize(I->RefPos, RefPosType, I->NIndex);
} }
if(I->has_atom_state_settings) {
VLASize(I->has_atom_state_settings, char, I->NIndex);
VLASize(I->atom_state_setting_id, int, I->NIndex);
}
VLASize(I->IdxToAtm, int, I->NIndex); VLASize(I->IdxToAtm, int, I->NIndex);
PRINTFD(I->State.G, FB_CoordSet) PRINTFD(I->State.G, FB_CoordSet)
" CoordSetPurge-Debug: I->IdxToAtm shrunk to %d\n", I->NIndex ENDFD; " CoordSetPurge-Debug: I->IdxToAtm shrunk to %d\n", I->NIndex ENDFD;
I->invalidateRep(cRepAll, cRepInvAtoms); /* this will free Color */ I->invalidateRep(cRepAll, cRepInvAtoms); /* this will free Color */
} }
PRINTFD(I->State.G, FB_CoordSet) PRINTFD(I->State.G, FB_CoordSet)
" CoordSetPurge-Debug: leaving NAtIndex %d NIndex %d...\n", " CoordSetPurge-Debug: leaving NAtIndex %d NIndex %d...\n",
I->NAtIndex, I->NIndex ENDFD; I->NAtIndex, I->NIndex ENDFD;
} }
skipping to change at line 480 skipping to change at line 609
v1 = I->Coord + 3 * a1; v1 = I->Coord + 3 * a1;
if(mode) { if(mode) {
add3f(v, v1, v1); add3f(v, v1, v1);
} else { } else {
copy3f(v, v1); copy3f(v, v1);
} }
return true; return true;
} }
/*========================================================================*/ /*========================================================================*/
int CoordSetMoveAtomLabel(CoordSet * I, int at, const float *v, int mode) int CoordSetMoveAtomLabel(CoordSet * I, int at, const float *v, const float *dif f)
{ {
ObjectMolecule *obj = I->Obj; ObjectMolecule *obj = I->Obj;
int a1 = I->atmToIdx(at); int a1 = I->atmToIdx(at);
int result = 0; int result = 0;
LabPosType *lp;
/* if label is valid, get the label offset /* if label is valid, get the label offset
* and set the new position relative to that */ * and set the new position relative to that */
if(a1 >= 0) { if(a1 >= 0) {
if(!I->LabPos) float at_offset[3];
I->LabPos = VLACalloc(LabPosType, I->NIndex); const float * at_offset_ptr;
if(I->LabPos) { int at_label_relative_mode = 0;
result = 1; AtomInfoType *ai = obj->AtomInfo + at;
lp = I->LabPos + a1;
if(!lp->mode) { AtomStateGetSetting_i(I->State.G, obj, I, a1, ai, cSetting_label_relative_mo
const float *lab_pos = de, &at_label_relative_mode);
SettingGet_3fv(obj->Obj.G, I->Setting, obj->Obj.Setting, switch (at_label_relative_mode){
cSetting_label_position); case 0:
copy3f(lab_pos, lp->pos); AtomStateGetSetting(I->State.G, obj, I, a1, ai, cSetting_label_placement_o
} ffset, &at_offset_ptr);
lp->mode = 1; add3f(v, at_offset_ptr, at_offset);
if(mode) { SettingSet(cSetting_label_placement_offset, at_offset, I, a1);
add3f(v, lp->offset, lp->offset); break;
} else { case 1: // screen relative
copy3f(v, lp->offset); case 2: // screen pixel space
{
float voff[3];
int width, height;
SceneGetWidthHeight(I->State.G, &width, &height);
if (at_label_relative_mode==1){
voff[0] = 2.f * diff[0] / width;
voff[1] = 2.f * diff[1] / height;
} else {
voff[0] = diff[0];
voff[1] = diff[1];
}
voff[2] = 0.f;
AtomStateGetSetting(I->State.G, obj, I, a1, ai, cSetting_label_screen_poi
nt, &at_offset_ptr);
add3f(voff, at_offset_ptr, at_offset);
SettingSet(cSetting_label_screen_point, at_offset, I, a1);
} }
break;
} }
} }
return (result); return (result);
} }
/*========================================================================*/ /*========================================================================*/
int CoordSetGetAtomVertex(CoordSet * I, int at, float *v) int CoordSetGetAtomVertex(CoordSet * I, int at, float *v)
{ {
int a1 = I->atmToIdx(at); int a1 = I->atmToIdx(at);
skipping to change at line 923 skipping to change at line 1065
PConvIntToPyObjAttr(atom, "id", ai->id); /* not necc. unique */ PConvIntToPyObjAttr(atom, "id", ai->id); /* not necc. unique */
PConvIntToPyObjAttr(atom, "index", index + 1); /* fragile */ PConvIntToPyObjAttr(atom, "index", index + 1); /* fragile */
} }
if(PyErr_Occurred()) if(PyErr_Occurred())
PyErr_Print(); PyErr_Print();
return (atom); return (atom);
#endif #endif
} }
/*========================================================================*/ /*========================================================================*/
void CoordSetAtomToTERStrVLA(PyMOLGlobals * G, char **charVLA, int *c, AtomInfoT
ype * ai,
int cnt)
{
int retain_ids = SettingGetGlobal_b(G, cSetting_pdb_retain_ids);
int ter_id;
VLACheck(*charVLA, char, (*c) + 1000);
if(retain_ids) {
ter_id = ai->id + 1;
} else {
ter_id = cnt + 1;
}
(*c) += sprintf((*charVLA) + (*c),
"TER %5i %3.3s %1.1s%4d%c\n", ter_id,
LexStr(G, ai->resn),
LexStr(G, ai->chain), ai->resv,
ai->getInscode(true));
}
/*========================================================================*/
void CoordSet::invalidateRep(int type, int level) void CoordSet::invalidateRep(int type, int level)
{ {
CoordSet * I = this; CoordSet * I = this;
int a; int a;
if(level >= cRepInvVisib) { if(level >= cRepInvVisib) {
if (I->Obj) if (I->Obj)
I->Obj->RepVisCacheValid = false; I->Obj->RepVisCacheValid = false;
} }
/* graphical representations need redrawing */ /* graphical representations need redrawing */
if(level == cRepInvVisib) { if(level == cRepInvVisib) {
skipping to change at line 1027 skipping to change at line 1146
else if(eff_level >= cRepInvExtColor) { else if(eff_level >= cRepInvExtColor) {
I->Rep[a]->fFree(I->Rep[a]); I->Rep[a]->fFree(I->Rep[a]);
I->Rep[a] = NULL; I->Rep[a] = NULL;
} }
} }
} }
if(level >= cRepInvCoord) { /* if coordinates change, then this map becomes invalid */ if(level >= cRepInvCoord) { /* if coordinates change, then this map becomes invalid */
MapFree(I->Coord2Idx); MapFree(I->Coord2Idx);
I->Coord2Idx = NULL; I->Coord2Idx = NULL;
ExecutiveInvalidateSelectionIndicatorsCGO(I->State.G);
SceneInvalidatePicking(I->State.G);
/* invalidate distances */ /* invalidate distances */
} }
#ifndef NO_MMLIBS
if (level >= cRepInvProp) {
if (validMMStereo == MMPYMOLX_PROP_STATE_AUTO)
validMMStereo = MMPYMOLX_PROP_STATE_NULL;
if (validTextType == MMPYMOLX_PROP_STATE_AUTO)
validTextType = MMPYMOLX_PROP_STATE_NULL;
}
#endif
SceneChanged(I->State.G); SceneChanged(I->State.G);
} }
/*========================================================================*/ /*========================================================================*/
#define RepUpdateMacro(I,rep,new_fn,state) {\ #define RepUpdateMacro(I,rep,new_fn,state) {\
if(I->Active[rep]&&(!G->Interrupt)) {\ if(I->Active[rep]&&(!G->Interrupt)) {\
if(!I->Rep[rep]) {\ if(!I->Rep[rep]) {\
I->Rep[rep]=new_fn(I,state);\ I->Rep[rep]=new_fn(I,state);\
if(I->Rep[rep]){ \ if(I->Rep[rep]){ \
I->Rep[rep]->fNew=(struct Rep *(*)(struct CoordSet *,int state))new_fn; \ I->Rep[rep]->fNew=(struct Rep *(*)(struct CoordSet *,int state))new_fn; \
SceneInvalidatePicking(G);\
} else { \ } else { \
I->Active[rep] = false; \ I->Active[rep] = false; \
} \ } \
} else {\ } else {\
if(I->Rep[rep]->fUpdate)\ if(I->Rep[rep]->fUpdate)\
I->Rep[rep] = I->Rep[rep]->fUpdate(I->Rep[rep],I,state,rep);\ I->Rep[rep] = I->Rep[rep]->fUpdate(I->Rep[rep],I,state,rep);\
}\ }\
}\ }\
OrthoBusyFast(I->State.G,rep,cRepCnt);\ OrthoBusyFast(I->State.G,rep,cRepCnt);\
} }
skipping to change at line 1111 skipping to change at line 1243
if(I->NIndex && (!I->Coord2Idx)) { /* NOTE: map based on stored coords */ if(I->NIndex && (!I->Coord2Idx)) { /* NOTE: map based on stored coords */
I->Coord2IdxReq = cutoff; I->Coord2IdxReq = cutoff;
I->Coord2IdxDiv = cutoff * 1.25F; I->Coord2IdxDiv = cutoff * 1.25F;
I->Coord2Idx = MapNew(I->State.G, I->Coord2IdxDiv, I->Coord, I->NIndex, NU LL); I->Coord2Idx = MapNew(I->State.G, I->Coord2IdxDiv, I->Coord, I->NIndex, NU LL);
if(I->Coord2IdxDiv < I->Coord2Idx->Div) if(I->Coord2IdxDiv < I->Coord2Idx->Div)
I->Coord2IdxDiv = I->Coord2Idx->Div; I->Coord2IdxDiv = I->Coord2Idx->Div;
} }
} }
} }
/*
* RepToTransparencySetting: maps rep to transparency setting
*/
static int RepToTransparencySetting(const int rep_id){
switch(rep_id){
// based on the rep,
// transparency is set with different settings
case cRepCyl:
return cSetting_stick_transparency;
case cRepSurface:
return cSetting_transparency;
case cRepSphere:
return cSetting_sphere_transparency;
case cRepEllipsoid:
return cSetting_ellipsoid_transparency;
case cRepCartoon:
return cSetting_cartoon_transparency;
case cRepRibbon:
return cSetting_ribbon_transparency;
}
return 0;
}
/*========================================================================*/ /*========================================================================*/
void CoordSet::render(RenderInfo * info) void CoordSet::render(RenderInfo * info)
{ {
CoordSet * I = this; CoordSet * I = this;
PyMOLGlobals *G = I->State.G; PyMOLGlobals *G = I->State.G;
PRINTFD(G, FB_CoordSet) PRINTFD(G, FB_CoordSet)
" CoordSetRender: entered (%p).\n", (void *) I ENDFD; " CoordSetRender: entered (%p).\n", (void *) I ENDFD;
if(!(info->ray || info->pick) && if(!(info->ray || info->pick) &&
(SettingGet_i(G, I->Setting, I->Obj->Obj.Setting, (SettingGet_i(G, I->Setting, I->Obj->Obj.Setting,
skipping to change at line 1139 skipping to change at line 1294
RepSphereRenderImmediate(I, info); RepSphereRenderImmediate(I, info);
if(I->Active[cRepCyl]) if(I->Active[cRepCyl])
RepCylBondRenderImmediate(I, info); RepCylBondRenderImmediate(I, info);
if(I->Active[cRepRibbon]) if(I->Active[cRepRibbon])
RepRibbonRenderImmediate(I, info); RepRibbonRenderImmediate(I, info);
} }
} else { } else {
int pass = info->pass; int pass = info->pass;
CRay *ray = info->ray; CRay *ray = info->ray;
Picking **pick = info->pick; Picking **pick = info->pick;
int a, aa; int a, aa, abit, aastart = 0, aaend = cRepCnt;
::Rep *r; ::Rep *r;
int float_labels = SettingGet_i(G, I->Setting,
I->Obj->Obj.Setting,
cSetting_float_labels);
int sculpt_vdw_vis_mode = SettingGet_i(G, I->Setting, int sculpt_vdw_vis_mode = SettingGet_i(G, I->Setting,
I->Obj->Obj.Setting, I->Obj->Obj.Setting,
cSetting_sculpt_vdw_vis_mode); cSetting_sculpt_vdw_vis_mode);
if((!pass) && sculpt_vdw_vis_mode && if((!pass) && sculpt_vdw_vis_mode &&
I->SculptCGO && (I->Obj->Obj.visRep & cRepCGOBit)) { I->SculptCGO && (I->Obj->Obj.visRep & cRepCGOBit)) {
if(ray) { if(ray) {
int ok = CGORenderRay(I->SculptCGO, ray, int ok = CGORenderRay(I->SculptCGO, ray, info,
ColorGet(G, I->Obj->Obj.Color), I->Setting, I->Obj- ColorGet(G, I->Obj->Obj.Color), NULL, I->Setting, I
>Obj.Setting); ->Obj->Obj.Setting);
if (!ok){ if (!ok){
CGOFree(I->SculptCGO); CGOFree(I->SculptCGO);
CGOFree(I->SculptShaderCGO); CGOFree(I->SculptShaderCGO);
I->SculptShaderCGO = I->SculptCGO = NULL;
} }
} else if(G->HaveGUI && G->ValidContext) { } else if(G->HaveGUI && G->ValidContext) {
if(!pick) { if(!pick) {
int use_shader = SettingGetGlobal_b(G, cSetting_use_shaders); int use_shader = SettingGetGlobal_b(G, cSetting_use_shaders);
if (use_shader){ if (use_shader){
if (!I->SculptShaderCGO){ if (!I->SculptShaderCGO){
CGO *convertcgo = NULL; CGO *convertcgo = NULL;
convertcgo = CGOCombineBeginEnd(I->SculptCGO, 0); convertcgo = CGOCombineBeginEnd(I->SculptCGO, 0);
if (convertcgo){ if (convertcgo){
I->SculptShaderCGO = CGOOptimizeToVBONotIndexed(convertcgo, 0); I->SculptShaderCGO = CGOOptimizeToVBONotIndexed(convertcgo, 0);
I->SculptShaderCGO->use_shader = I->SculptShaderCGO->enable_shade rs = true; I->SculptShaderCGO->use_shader = true;
CGOFree(convertcgo); CGOFree(convertcgo);
} }
} }
} else if (I->SculptShaderCGO){ } else {
CGOFree(I->SculptShaderCGO); CGOFree(I->SculptShaderCGO);
I->SculptShaderCGO = NULL;
} }
if (I->SculptShaderCGO){ if (I->SculptShaderCGO){
CGORenderGL(I->SculptShaderCGO, ColorGet(G, I->Obj->Obj.Color), CGORenderGL(I->SculptShaderCGO, NULL,
I->Setting, I->Obj->Obj.Setting, info, NULL); I->Setting, I->Obj->Obj.Setting, info, NULL);
} else { } else {
CGORenderGL(I->SculptCGO, ColorGet(G, I->Obj->Obj.Color), CGORenderGL(I->SculptCGO, NULL,
I->Setting, I->Obj->Obj.Setting, info, NULL); I->Setting, I->Obj->Obj.Setting, info, NULL);
} }
} }
} }
} }
for(aa = 0; aa < cRepCnt; aa++) { if (pick){
int pick_labels = SettingGet_i(G, I->Setting,
I->Obj->Obj.Setting,
cSetting_pick_labels);
if (pick_labels == 2){ // only pick labels
aastart = cRepLabel;
aaend = aastart + 1;
}
}
for(aa = aastart; aa < aaend; aa++) {
if(aa == cRepSurface) { /* reorder */ if(aa == cRepSurface) { /* reorder */
a = cRepCell; a = cRepCell;
} else if(aa == cRepCell) { } else if(aa == cRepCell) {
a = cRepSurface; a = cRepSurface;
} else { } else {
a = aa; a = aa;
} }
abit = (1 << a);
if(I->Active[a] && I->Rep[a]) { if(I->Active[a] && I->Rep[a]) {
r = I->Rep[a]; r = I->Rep[a];
if(!ray) { if(!ray) {
ObjectUseColor((CObject *) I->Obj); ObjectUseColor((CObject *) I->Obj);
} else { } else {
if(I->Obj) if(I->Obj)
ray->wobble( ray->wobble(
SettingGet_i(G, I->Setting, SettingGet_i(G, I->Setting,
I->Obj->Obj.Setting, I->Obj->Obj.Setting,
cSetting_ray_texture), cSetting_ray_texture),
skipping to change at line 1223 skipping to change at line 1384
ray->color3fv(ColorGet(G, I->Obj->Obj.Color)); ray->color3fv(ColorGet(G, I->Obj->Obj.Color));
} }
if(r->fRender) { /* do OpenGL rendering in three passes */ if(r->fRender) { /* do OpenGL rendering in three passes */
if(ray || pick) { if(ray || pick) {
/* here we need to iterate through and apply coordinate set matrices */ /* here we need to iterate through and apply coordinate set matrices */
r->fRender(r, info); r->fRender(r, info);
} else { } else {
bool t_mode_3 = SettingGetGlobal_i(G, cSetting_transparency_mode) ==
3;
bool render_both = t_mode_3; // render both opaque (1) and transpar
ent (-1) pass if t_mode_3
/* here we need to iterate through and apply coordinate set matrices */ /* here we need to iterate through and apply coordinate set matrices */
switch (a) { switch (a) {
case cRepVolume:
{
int t_mode = SettingGetGlobal_i(G, cSetting_transparency_mode);
if (t_mode == 3 && pass == -1){
r->fRender(r, info);
}
}
break;
case cRepLabel: case cRepLabel:
if(float_labels && (pass == -1)) {
r->fRender(r, info); int t_mode_3 = SettingGetGlobal_i(G, cSetting_transparency_mode)
else if(pass == 1) == 3;
r->fRender(r, info); if (pass == -1 || (t_mode_3 && pass == 1))
r->fRender(r, info);
}
break; break;
case cRepNonbondedSphere:
case cRepRibbon:
case cRepDot: case cRepDot:
case cRepCGO: case cRepCGO:
case cRepCallback: case cRepCallback:
if(pass == 1) if(pass == 1)
r->fRender(r, info); r->fRender(r, info);
break; break;
case cRepLine: case cRepLine:
case cRepMesh: case cRepMesh:
case cRepDash: case cRepDash:
case cRepNonbonded:
case cRepCell: case cRepCell:
case cRepExtent: case cRepExtent:
if(!pass) if(!pass)
r->fRender(r, info); r->fRender(r, info);
break; break;
case cRepCyl: /* render sticks differently depending on transpa
rency */
if(SettingGet_f(G, r->cs->Setting,
r->obj->Setting, cSetting_stick_transparency) > 0.
0001) {
if(pass == -1)
r->fRender(r, info);
} else if(pass == 1){
r->fRender(r, info);
}
break;
case cRepSurface:
if(info->alpha_cgo) {
if(pass == 1)
r->fRender(r, info);
} else {
if(SettingGet_f(G, r->cs->Setting,
r->obj->Setting, cSetting_transparency) > 0.0001
) {
if(pass == -1)
r->fRender(r, info);
} else if(pass == 1)
r->fRender(r, info);
}
break;
case cRepSphere: /* render spheres differently depending on transp
arency */
if(SettingGet_f(G, r->cs->Setting,
r->obj->Setting, cSetting_sphere_transparency) > 0
.0001) {
if(pass == -1)
r->fRender(r, info);
} else if(pass == 1)
r->fRender(r, info);
break;
case cRepEllipsoid: /* render spheres differently depending o
n transparency */
if(SettingGet_f(G, r->cs->Setting,
r->obj->Setting, cSetting_ellipsoid_transparency)
> 0.0001) {
if(pass == -1)
r->fRender(r, info);
} else if(pass == 1)
r->fRender(r, info);
break;
case cRepCartoon: case cRepCartoon:
if(info->alpha_cgo) { case cRepNonbonded:
if(pass == 1) case cRepRibbon:
r->fRender(r, info); render_both = false; // cartoon and nonbonded do not have atom-lev
} else { el transparency
if(SettingGet_f(G, r->cs->Setting, case cRepNonbondedSphere:
r->obj->Setting, case cRepSurface:
cSetting_cartoon_transparency) > 0.0001) { case cRepEllipsoid:
if(pass == -1) case cRepCyl:
case cRepSphere:
{
if (render_both){
// for transparency_mode 3, render both opaque and transparent
pass
if (pass != 0){
r->fRender(r, info); r->fRender(r, info);
} else if(pass == 1) }
r->fRender(r, info); } else {
bool checkAlphaCGO = abit & (cRepSurfaceBit | cRepCartoonBit);
int check_setting = RepToTransparencySetting(a);
bool cont = true;
if (checkAlphaCGO){
if(info->alpha_cgo) {
if(pass == 1){
r->fRender(r, info);
}
cont = false;
}
}
if (cont){
if(check_setting && SettingGet_f(G, r->cs->Setting,
r->obj->Setting, check_sett
ing) > 0.0001) {
/* if object has transparency, only render in -1 pass */
if(pass == -1)
r->fRender(r, info);
} else if(pass == 1){
r->fRender(r, info);
}
}
}
} }
break; break;
} }
} }
} }
/* if(ray) /* if(ray)
ray->fWobble(ray,0,NULL); */ ray->fWobble(ray,0,NULL); */
} }
} }
} }
skipping to change at line 1359 skipping to change at line 1513
// copy VLAs // copy VLAs
I->Coord = VLACopy2(cs->Coord); I->Coord = VLACopy2(cs->Coord);
I->LabPos = VLACopy2(cs->LabPos); I->LabPos = VLACopy2(cs->LabPos);
I->RefPos = VLACopy2(cs->RefPos); I->RefPos = VLACopy2(cs->RefPos);
I->AtmToIdx = VLACopy2(cs->AtmToIdx); I->AtmToIdx = VLACopy2(cs->AtmToIdx);
I->IdxToAtm = VLACopy2(cs->IdxToAtm); I->IdxToAtm = VLACopy2(cs->IdxToAtm);
UtilZeroMem(I->Rep, sizeof(::Rep *) * cRepCnt); UtilZeroMem(I->Rep, sizeof(::Rep *) * cRepCnt);
#ifdef _PYMOL_IP_PROPERTIES
#endif
I->Setting = NULL; I->Setting = NULL;
I->atom_state_setting_id = NULL;
I->has_atom_state_settings = NULL;
I->SculptCGO = NULL; I->SculptCGO = NULL;
I->SculptShaderCGO = NULL; I->SculptShaderCGO = NULL;
I->TmpLinkBond = NULL; I->TmpLinkBond = NULL;
I->TmpBond = NULL; I->TmpBond = NULL;
I->Spheroid = NULL; I->Spheroid = NULL;
I->SpheroidNormal = NULL; I->SpheroidNormal = NULL;
I->Coord2Idx = NULL; I->Coord2Idx = NULL;
return (I); return (I);
} }
skipping to change at line 1474 skipping to change at line 1633
I->NAtIndex = I->NIndex; I->NAtIndex = I->NIndex;
} }
/*========================================================================*/ /*========================================================================*/
void CoordSet::fFree() void CoordSet::fFree()
{ {
CoordSet * I = this; CoordSet * I = this;
int a; int a;
ObjectMolecule *obj; ObjectMolecule *obj;
if(I) { if(I) {
#ifdef _PYMOL_IP_PROPERTIES
#endif
if (I->has_atom_state_settings){
for(a = 0; a < I->NIndex; a++){
if (I->has_atom_state_settings[a]){
SettingUniqueDetachChain(I->State.G, I->atom_state_setting_id[a]);
}
}
VLAFreeP(I->has_atom_state_settings);
VLAFreeP(I->atom_state_setting_id);
}
for(a = 0; a < cRepCnt; a++) for(a = 0; a < cRepCnt; a++)
if(I->Rep[a]) if(I->Rep[a])
I->Rep[a]->fFree(I->Rep[a]); I->Rep[a]->fFree(I->Rep[a]);
obj = I->Obj; obj = I->Obj;
if(obj) if(obj)
if(obj->DiscreteFlag) /* remove references to the atoms in discrete ob jects */ if(obj->DiscreteFlag) /* remove references to the atoms in discrete ob jects */
for(a = 0; a < I->NIndex; a++) { for(a = 0; a < I->NIndex; a++) {
obj->DiscreteAtmToIdx[I->IdxToAtm[a]] = -1; obj->DiscreteAtmToIdx[I->IdxToAtm[a]] = -1;
obj->DiscreteCSet[I->IdxToAtm[a]] = NULL; obj->DiscreteCSet[I->IdxToAtm[a]] = NULL;
} }
skipping to change at line 1513 skipping to change at line 1684
} }
void LabPosTypeCopy(const LabPosType * src, LabPosType * dst){ void LabPosTypeCopy(const LabPosType * src, LabPosType * dst){
dst->mode = src->mode; dst->mode = src->mode;
copy3f(src->pos, dst->pos); copy3f(src->pos, dst->pos);
copy3f(src->offset, dst->offset); copy3f(src->offset, dst->offset);
} }
void RefPosTypeCopy(const RefPosType * src, RefPosType * dst){ void RefPosTypeCopy(const RefPosType * src, RefPosType * dst){
copy3f(src->coord, dst->coord); copy3f(src->coord, dst->coord);
dst->specified = src->specified; dst->specified = src->specified;
} }
#ifndef _PYMOL_NOPY
int CoordSetSetSettingFromPyObject(PyMOLGlobals * G, CoordSet *cs, int at, int s
etting_id, PyObject *val){
if (val == Py_None)
val = NULL;
if (!val) {
if (!cs->has_atom_state_settings ||
!cs->has_atom_state_settings[at])
return true;
}
CoordSetCheckUniqueID(G, cs, at);
cs->has_atom_state_settings[at] = true;
return SettingUniqueSetPyObject(G, cs->atom_state_setting_id[at], setting_id,
val);
}
#endif
int CoordSetCheckSetting(PyMOLGlobals * G, CoordSet *cs, int at, int setting_id)
{
if(!cs->has_atom_state_settings || !cs->has_atom_state_settings[at]) {
return 0;
} else {
if(!SettingUniqueCheck(G, cs->atom_state_setting_id[at], setting_id)) {
return 0;
} else {
return 1;
}
}
}
PyObject *SettingGetIfDefinedPyObject(PyMOLGlobals * G, CoordSet *cs, int at, in
t setting_id){
if(cs->has_atom_state_settings && cs->has_atom_state_settings[at]){
return SettingUniqueGetPyObject(G, cs->atom_state_setting_id[at], setting_id
);
}
return NULL;
}
int CoordSetCheckUniqueID(PyMOLGlobals * G, CoordSet *I, int at){
if (!I->atom_state_setting_id){
I->atom_state_setting_id = VLACalloc(int, I->NIndex);
}
if (!I->has_atom_state_settings){
I->has_atom_state_settings = VLACalloc(char, I->NIndex);
}
if (!I->atom_state_setting_id[at]){
I->atom_state_setting_id[at] = AtomInfoGetNewUniqueID(G);
}
return I->atom_state_setting_id[at];
}
template <typename V>
void AtomStateGetSetting(ATOMSTATEGETSETTINGARGS, V * out) {
if (cs->has_atom_state_settings &&
cs->has_atom_state_settings[idx] &&
SettingUniqueGetIfDefined(G, cs->atom_state_setting_id[idx], setting_id, o
ut))
return;
if (AtomSettingGetIfDefined(G, ai, setting_id, out))
return;
*out = SettingGet<V>(G, cs->Setting, obj->Obj.Setting, setting_id);
}
template void AtomStateGetSetting(ATOMSTATEGETSETTINGARGS, int * out);
template void AtomStateGetSetting(ATOMSTATEGETSETTINGARGS, float * out);
template void AtomStateGetSetting(ATOMSTATEGETSETTINGARGS, const float ** out);
 End of changes. 47 change blocks. 
128 lines changed or deleted 304 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)