"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer2/ObjectMolecule.cpp" between
pymol-v1.8.6.0.tar.bz2 and pymol-v2.1.0.tar.bz2

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.

ObjectMolecule.cpp  (pymol-v1.8.6.0.tar.bz2):ObjectMolecule.cpp  (pymol-v2.1.0.tar.bz2)
skipping to change at line 61 skipping to change at line 61
#include"CGO.h" #include"CGO.h"
#include"Editor.h" #include"Editor.h"
#include"Sculpt.h" #include"Sculpt.h"
#include"OVContext.h" #include"OVContext.h"
#include"OVOneToOne.h" #include"OVOneToOne.h"
#include"OVLexicon.h" #include"OVLexicon.h"
#include"ListMacros.h" #include"ListMacros.h"
#include"File.h" #include"File.h"
#include "Lex.h" #include "Lex.h"
#include "MolV3000.h" #include "MolV3000.h"
#include "HydrogenAdder.h"
#ifdef _WEBGL #ifdef _WEBGL
#endif #endif
#define cMaxNegResi 100 #define cMaxNegResi 100
#define ntrim ParseNTrim #define ntrim ParseNTrim
#define nextline ParseNextLine #define nextline ParseNextLine
#define ncopy ParseNCopy #define ncopy ParseNCopy
#define nskip ParseNSkip #define nskip ParseNSkip
skipping to change at line 423 skipping to change at line 424
int frozen = SettingGetIfDefined_i(I->Obj.G, I->Obj.Setting, cSetting_state, & objState); int frozen = SettingGetIfDefined_i(I->Obj.G, I->Obj.Setting, cSetting_state, & objState);
/* if frozen print (blue) STATE / NSTATES /* if frozen print (blue) STATE / NSTATES
* if not frozen, print STATE/NSTATES * if not frozen, print STATE/NSTATES
* if beyond NSTATES, print * /NSTATES. * if beyond NSTATES, print * /NSTATES.
*/ */
if(frozen) { /* frozen color */ if(frozen) { /* frozen color */
frozen_str = "\\789"; frozen_str = "\\789";
} else { } else {
if(state+1>I->NCSet) { /* beyond this object's number of states */ if (I->DiscreteFlag) { /* discrete states */
frozen_str = "--"; frozen_str = "\\993";
} else { /* normal case */ } else { /* normal case */
frozen_str = ""; frozen_str = "";
} }
} }
switch(counter_mode) { switch(counter_mode) {
case 0: /* off */ case 0: /* off */
show_state = show_as_fraction = 0; show_state = show_as_fraction = 0;
break; break;
case 2: /* just state */ case 2: /* just state */
skipping to change at line 479 skipping to change at line 480
} }
} }
} else { /* no state */ } else { /* no state */
n = snprintf(ch, len, "%s", cs->Name); n = snprintf(ch, len, "%s", cs->Name);
} }
} else { /* no coord set, can be an N-state object missing a CSet */ } else { /* no coord set, can be an N-state object missing a CSet */
} }
} else { /* state > NCSet, out of range due to other object or global settin g */ } else { /* state > NCSet, out of range due to other object or global settin g */
if(show_state) { if(show_state) {
if(show_as_fraction) { if(show_as_fraction) {
n = snprintf(ch, len, "%s/%d", frozen_str, I->NCSet); n = snprintf(ch, len, "%s--/%d", frozen_str, I->NCSet);
} else { /* no fraction */ } else { /* no fraction */
n = snprintf(ch, len, "%s", frozen_str); n = snprintf(ch, len, "%s--", frozen_str);
} }
} }
} }
} else if (state == -1) { } else if (state == -1) {
// all states // all states
n = snprintf(ch, len, "%s*/%d", frozen_str, I->NCSet); n = snprintf(ch, len, "%s*/%d", frozen_str, I->NCSet);
} else { } else {
/* blank out the title if outside the valid # of states */ /* blank out the title if outside the valid # of states */
} }
skipping to change at line 851 skipping to change at line 852
if(cs && SettingGet_b(I->Obj.G, I->Obj.Setting, NULL, cSetting_static_sing letons)) { if(cs && SettingGet_b(I->Obj.G, I->Obj.Setting, NULL, cSetting_static_sing letons)) {
ObjectStateLeftCombineMatrixR44d(&cs->State, dbl_matrix); ObjectStateLeftCombineMatrixR44d(&cs->State, dbl_matrix);
} }
} }
} }
} }
/*========================================================================*/ /*========================================================================*/
static int ObjectMoleculeFixSeleHydrogens(ObjectMolecule * I, int sele, int stat e) static int ObjectMoleculeFixSeleHydrogens(ObjectMolecule * I, int sele, int stat e)
{ {
int a, b; int a;
int n;
int seleFlag = false; int seleFlag = false;
int h_idx; AtomInfoType *ai0;
float fixed[3], v0[3], v1[3], sought[3];
AtomInfoType *ai0, *ai1;
int ok = true; int ok = true;
ai0 = I->AtomInfo; ai0 = I->AtomInfo;
for(a = 0; a < I->NAtom; a++) { for(a = 0; a < I->NAtom; a++) {
if(SelectorIsMember(I->Obj.G, ai0->selEntry, sele)) { if(SelectorIsMember(I->Obj.G, ai0->selEntry, sele)) {
seleFlag = true; seleFlag = true;
break; break;
} }
ai0++; ai0++;
} }
skipping to change at line 878 skipping to change at line 876
seleFlag = false; seleFlag = false;
if(!ObjectMoleculeVerifyChemistry(I, state)) { if(!ObjectMoleculeVerifyChemistry(I, state)) {
ErrMessage(I->Obj.G, " AddHydrogens", "missing chemical geometry informati on."); ErrMessage(I->Obj.G, " AddHydrogens", "missing chemical geometry informati on.");
} else { } else {
if (ok) if (ok)
ok &= ObjectMoleculeUpdateNeighbors(I); ok &= ObjectMoleculeUpdateNeighbors(I);
ai0 = I->AtomInfo; ai0 = I->AtomInfo;
for(a = 0; a < I->NAtom; a++) { for(a = 0; a < I->NAtom; a++) {
if(!ai0->isHydrogen()) { /* only do heavies */ if(!ai0->isHydrogen()) { /* only do heavies */
if(SelectorIsMember(I->Obj.G, ai0->selEntry, sele)) { if(SelectorIsMember(I->Obj.G, ai0->selEntry, sele)) {
n = I->Neighbor[a] + 1; for(StateIterator iter(I->Obj.G, I->Obj.Setting, state, I->NCSet);
while((h_idx = I->Neighbor[n]) >= 0) { iter.next();) {
ai1 = I->AtomInfo + h_idx; auto cs = I->CSet[iter.state];
if(ai1->isHydrogen()) { if (!cs)
for(b = 0; b < I->NCSet; b++) { /* iterate through each coordina continue;
te set */
if(ObjectMoleculeGetAtomVertex(I, b, a, v0) && #ifndef _PYMOL_NO_UNDO
ObjectMoleculeGetAtomVertex(I, b, h_idx, v1)) { #endif
/* current direction */
float l; seleFlag |= ObjectMoleculeSetMissingNeighborCoords(I, cs, a, true)
subtract3f(v1, v0, sought); ;
l = length3f(sought); /* use the current length */
if(ObjectMoleculeFindOpenValenceVector(I, b, a, fixed, sough
t, h_idx)) {
scale3f(fixed, l, fixed);
add3f(fixed, v0, fixed);
ObjectMoleculeSetAtomVertex(I, b, h_idx, fixed);
seleFlag = true;
}
}
}
}
n += 2;
} }
} }
} }
ai0++; ai0++;
} }
} }
if(seleFlag) if(seleFlag)
ObjectMoleculeInvalidate(I, cRepAll, cRepInvAll, -1); ObjectMoleculeInvalidate(I, cRepAll, cRepInvAll, -1);
} }
return ok; return ok;
skipping to change at line 1040 skipping to change at line 1026
if(!shift) if(!shift)
shift = zerovector; shift = zerovector;
if(interval < 1) if(interval < 1)
interval = 1; interval = 1;
icnt = interval; icnt = interval;
#define BUFSIZE 4194304 #define BUFSIZE 4194304
#define GETTING_LOW 10000 #define GETTING_LOW 10000
f = fopen(fname, "rb"); f = pymol_fopen(fname, "rb");
if(!f) { if(!f) {
ErrMessage(G, "ObjectMoleculeLoadTRJFile", "Unable to open file!"); ErrMessage(G, "ObjectMoleculeLoadTRJFile", "Unable to open file!");
} else { } else {
if(I->CSTmpl) { if(I->CSTmpl) {
cs = CoordSetCopy(I->CSTmpl); cs = CoordSetCopy(I->CSTmpl);
} else if (I->NCSet > 0) { } else if (I->NCSet > 0) {
cs = CoordSetCopy(I->CSet[0]); cs = CoordSetCopy(I->CSet[0]);
} else { } else {
PRINTFB(G, FB_ObjectMolecule, FB_Errors) PRINTFB(G, FB_ObjectMolecule, FB_Errors)
" ObjMolLoadTRJFile: Missing topology" ENDFB(G); " ObjMolLoadTRJFile: Missing topology" ENDFB(G);
skipping to change at line 2810 skipping to change at line 2796
CoordSet *cs = I->CSet[state]; CoordSet *cs = I->CSet[state];
result = &cs->State; result = &cs->State;
} }
} }
return result; return result;
} }
/*========================================================================*/ /*========================================================================*/
static CSetting **ObjectMoleculeGetSettingHandle(ObjectMolecule * I, int state) static CSetting **ObjectMoleculeGetSettingHandle(ObjectMolecule * I, int state)
{ {
if (state < -1) {
state = I->getState();
}
if(state < 0) { if(state < 0) {
return (&I->Obj.Setting); return (&I->Obj.Setting);
} else if(state < I->NCSet) { } else if(state < I->NCSet) {
if(I->CSet[state]) { if(I->CSet[state]) {
return (&I->CSet[state]->Setting); return (&I->CSet[state]->Setting);
} else { } else {
return (NULL); return (NULL);
} }
} else { } else {
skipping to change at line 2849 skipping to change at line 2838
result = true; result = true;
} }
return (result); return (result);
} }
/*========================================================================*/ /*========================================================================*/
const char *ObjectMoleculeGetStateTitle(ObjectMolecule * I, int state) const char *ObjectMoleculeGetStateTitle(ObjectMolecule * I, int state)
{ {
char *result = NULL; char *result = NULL;
if(state < 0) if(state < 0)
state = I->NCSet - 1; state = I->getState();
if(state >= I->NCSet) { if(state < 0 || state >= I->NCSet) {
PRINTFB(I->Obj.G, FB_ObjectMolecule, FB_Errors) PRINTFB(I->Obj.G, FB_ObjectMolecule, FB_Errors)
"Error: invalid state %d\n", state + 1 ENDFB(I->Obj.G); "Error: invalid state %d\n", state + 1 ENDFB(I->Obj.G);
} else if(!I->CSet[state]) { } else if(!I->CSet[state]) {
PRINTFB(I->Obj.G, FB_ObjectMolecule, FB_Errors) PRINTFB(I->Obj.G, FB_ObjectMolecule, FB_Errors)
"Error: empty state %d\n", state + 1 ENDFB(I->Obj.G); "Error: empty state %d\n", state + 1 ENDFB(I->Obj.G);
} else { } else {
result = I->CSet[state]->Name; result = I->CSet[state]->Name;
} }
return (result); return (result);
} }
/*========================================================================*/ /*========================================================================*/
/* /*
* Get the effective state (0-indexed) of an object, based on the "state" and * Get the effective state (0-indexed) of an object, based on the "state" and
* "static_singletons" settings. * "static_singletons" settings.
*/ */
int ObjectMolecule::getState() { int ObjectMolecule::getState() const {
if (NCSet == 1 if (NCSet == 1
&& SettingGet_b(Obj.G, Obj.Setting, NULL, cSetting_static_singletons)) && SettingGet_b(Obj.G, Obj.Setting, NULL, cSetting_static_singletons))
return 0; return 0;
return SettingGet_i(Obj.G, Obj.Setting, NULL, cSetting_state) - 1; return SettingGet_i(Obj.G, Obj.Setting, NULL, cSetting_state) - 1;
} }
/*========================================================================*/ /*========================================================================*/
void ObjectMoleculeRenderSele(ObjectMolecule * I, int curState, int sele, int vi s_only SELINDICATORARG) void ObjectMoleculeRenderSele(ObjectMolecule * I, int curState, int sele, int vi s_only SELINDICATORARG)
{ {
skipping to change at line 3075 skipping to change at line 3064
a = 0; a = 0;
atomCount = 0; atomCount = 0;
while(*p) { while(*p) {
VLACheck(atInfo, AtomInfoType, atomCount); VLACheck(atInfo, AtomInfoType, atomCount);
ai = atInfo + atomCount; ai = atInfo + atomCount;
if(!tinker_xyz) { if(!tinker_xyz) {
valid_atom = true; valid_atom = true;
p = ParseWordCopy(cc, p, sizeof(AtomName) - 1); p = ParseWordCopy(cc, p, MAXLINELEN - 1);
UtilCleanStr(cc); UtilCleanStr(cc);
if(!cc[0]) if(!cc[0])
valid_atom = false; valid_atom = false;
if(valid_atom) { if(valid_atom) {
strncpy(ai->elem, cc, cElemNameLen);
ai->name = LexIdx(G, cc); ai->name = LexIdx(G, cc);
ai->rank = atomCount; ai->rank = atomCount;
ai->id = atomCount + 1; ai->id = atomCount + 1;
VLACheck(coord, float, a * 3 + 2); VLACheck(coord, float, a * 3 + 2);
p = ParseWordCopy(cc, p, MAXLINELEN - 1); p = ParseWordCopy(cc, p, MAXLINELEN - 1);
if(sscanf(cc, "%f", coord + a) != 1) if(sscanf(cc, "%f", coord + a) != 1)
valid_atom = false; valid_atom = false;
p = ParseWordCopy(cc, p, MAXLINELEN - 1); p = ParseWordCopy(cc, p, MAXLINELEN - 1);
skipping to change at line 3106 skipping to change at line 3096
ai->resn = LexIdx(G, "UNK"); ai->resn = LexIdx(G, "UNK");
ai->alt[0] = 0; ai->alt[0] = 0;
ai->chain = 0; ai->chain = 0;
ai->resv = atomCount + 1; ai->resv = atomCount + 1;
ai->q = 1.0; ai->q = 1.0;
ai->b = 0.0; ai->b = 0.0;
ai->segi = 0; ai->segi = 0;
ai->elem[0] = 0; /* let atom info guess/infer atom type */
ai->visRep = auto_show; ai->visRep = auto_show;
/* in the absense of external tinker information, assume hetatm */ /* in the absense of external tinker information, assume hetatm */
ai->hetatm = 1; ai->hetatm = 1;
AtomInfoAssignParameters(G, ai); AtomInfoAssignParameters(G, ai);
AtomInfoAssignColors(G, ai); AtomInfoAssignColors(G, ai);
} }
skipping to change at line 3382 skipping to change at line 3371
AtomInfoUniquefyNames(I->Obj.G, I->AtomInfo, I->NAtom, nai, NULL, nH); AtomInfoUniquefyNames(I->Obj.G, I->AtomInfo, I->NAtom, nai, NULL, nH);
if (ok) if (ok)
ok &= ObjectMoleculeMerge(I, nai, cs, false, cAIC_AllMask, true); / * will free nai and cs->TmpLinkBond */ ok &= ObjectMoleculeMerge(I, nai, cs, false, cAIC_AllMask, true); / * will free nai and cs->TmpLinkBond */
if (ok) if (ok)
ok &= ObjectMoleculeExtendIndices(I, state); ok &= ObjectMoleculeExtendIndices(I, state);
if (ok) if (ok)
ok &= ObjectMoleculeUpdateNeighbors(I); ok &= ObjectMoleculeUpdateNeighbors(I);
// copy of the idx -> atm mapping
std::vector<int> mergedIdxToAtm(cs->IdxToAtm, cs->IdxToAtm + cs->NInde
x);
for(b = 0; ok && b < I->NCSet; b++) { /* add coordinate into the coordinate set */ for(b = 0; ok && b < I->NCSet; b++) { /* add coordinate into the coordinate set */
tcs = I->CSet[b]; tcs = I->CSet[b];
if(tcs) { if(tcs) {
int idx = 0;
for(a = 0; ok && a < nH; a++) { for(a = 0; ok && a < nH; a++) {
ObjectMoleculeGetAtomVertex(I, b, index[a], v0); if(!ObjectMoleculeGetAtomVertex(I, b, index[a], v0)) {
continue;
}
ObjectMoleculeFindOpenValenceVector(I, b, index[a], v, NULL, -1) ; ObjectMoleculeFindOpenValenceVector(I, b, index[a], v, NULL, -1) ;
d = AtomInfoGetBondLength(I->Obj.G, I->AtomInfo + index[a], &fak eH); d = AtomInfoGetBondLength(I->Obj.G, I->AtomInfo + index[a], &fak eH);
scale3f(v, d, v); scale3f(v, d, v);
add3f(v0, v, cs->Coord + 3 * a); add3f(v0, v, cs->Coord + 3 * idx);
cs->IdxToAtm[idx] = mergedIdxToAtm[a];
++idx;
} }
cs->NIndex = idx;
if (ok) if (ok)
ok &= CoordSetMerge(I, tcs, cs); ok &= CoordSetMerge(I, tcs, cs);
} }
} }
FreeP(index); FreeP(index);
cs->fFree(); cs->fFree();
if (ok) if (ok)
ok &= ObjectMoleculeSort(I); ok &= ObjectMoleculeSort(I);
ObjectMoleculeUpdateIDNumbers(I); ObjectMoleculeUpdateIDNumbers(I);
} else { } else {
skipping to change at line 4422 skipping to change at line 4420
void ObjectMoleculeReplaceAtom(ObjectMolecule * I, int index, AtomInfoType * ai) void ObjectMoleculeReplaceAtom(ObjectMolecule * I, int index, AtomInfoType * ai)
{ {
if((index >= 0) && (index <= I->NAtom)) { if((index >= 0) && (index <= I->NAtom)) {
memcpy(I->AtomInfo + index, ai, sizeof(AtomInfoType)); memcpy(I->AtomInfo + index, ai, sizeof(AtomInfoType));
ObjectMoleculeInvalidate(I, cRepAll, cRepInvAtoms, -1); ObjectMoleculeInvalidate(I, cRepAll, cRepInvAtoms, -1);
/* could we put in a refinement step here? */ /* could we put in a refinement step here? */
} }
} }
/*========================================================================*/ /*========================================================================*/
int ObjectMoleculePrepareAtom(ObjectMolecule * I, int index, AtomInfoType * ai) int ObjectMoleculePrepareAtom(ObjectMolecule * I, int index, AtomInfoType * ai,
bool uniquefy)
{ {
/* match existing properties of the old atom */ /* match existing properties of the old atom */
AtomInfoType *ai0; AtomInfoType *ai0;
int ok = true; int ok = true;
if((index >= 0) && (index <= I->NAtom)) { if((index >= 0) && (index <= I->NAtom)) {
ai0 = I->AtomInfo + index; ai0 = I->AtomInfo + index;
ai->resv = ai0->resv; ai->resv = ai0->resv;
ai->hetatm = ai0->hetatm; ai->hetatm = ai0->hetatm;
ai->flags = ai0->flags; ai->flags = ai0->flags;
ai->geom = ai0->geom; /* ? */
if (!ai->geom)
ai->geom = ai0->geom;
ai->discrete_state = ai0->discrete_state;
ai->q = ai0->q; ai->q = ai0->q;
ai->b = ai0->b; ai->b = ai0->b;
strcpy(ai->alt, ai0->alt); strcpy(ai->alt, ai0->alt);
ai->inscode = ai0->inscode; ai->inscode = ai0->inscode;
LexAssign(I->Obj.G, ai->segi, ai0->segi); LexAssign(I->Obj.G, ai->segi, ai0->segi);
LexAssign(I->Obj.G, ai->chain, ai0->chain); LexAssign(I->Obj.G, ai->chain, ai0->chain);
LexAssign(I->Obj.G, ai->resn, ai0->resn); LexAssign(I->Obj.G, ai->resn, ai0->resn);
ai->visRep = ai0->visRep; ai->visRep = ai0->visRep;
ai->id = -1; ai->id = -1;
#ifdef _PYMOL_IP_EXTRAS #ifdef _PYMOL_IP_EXTRAS
ai->oldid = -1; ai->oldid = -1;
#endif #endif
ai->rank = -1; ai->rank = -1;
AtomInfoUniquefyNames(I->Obj.G, I->AtomInfo, I->NAtom, ai, NULL, 1);
AtomInfoAssignParameters(I->Obj.G, ai); AtomInfoAssignParameters(I->Obj.G, ai);
if (uniquefy) {
AtomInfoUniquefyNames(I->Obj.G, I->AtomInfo, I->NAtom, ai, NULL, 1);
}
if((ai->elem[0] == ai0->elem[0]) && (ai->elem[1] == ai0->elem[1])) if((ai->elem[0] == ai0->elem[0]) && (ai->elem[1] == ai0->elem[1]))
ai->color = ai0->color; ai->color = ai0->color;
else if((ai->elem[0] == 'C') && (ai->elem[1] == 0)) { else if((ai->elem[0] == 'C') && (ai->elem[1] == 0)) {
int n, index2; int n, index2;
int found = false; int found = false;
if (ok) if (ok)
ok &= ObjectMoleculeUpdateNeighbors(I); ok &= ObjectMoleculeUpdateNeighbors(I);
n = I->Neighbor[index] + 1; n = I->Neighbor[index] + 1;
while(ok && (index2 = I->Neighbor[n]) >= 0) { while(ok && (index2 = I->Neighbor[n]) >= 0) {
AtomInfoType *ai1 = I->AtomInfo + index2; AtomInfoType *ai1 = I->AtomInfo + index2;
skipping to change at line 7641 skipping to change at line 7648
PConvPyListToFloatArray(tmp, &cset->SpheroidNormal); PConvPyListToFloatArray(tmp, &cset->SpheroidNormal);
Py_DECREF(tmp); Py_DECREF(tmp);
} }
} }
if(PyObject_HasAttrString(model, "spacegroup") && if(PyObject_HasAttrString(model, "spacegroup") &&
PyObject_HasAttrString(model, "cell")) { PyObject_HasAttrString(model, "cell")) {
CSymmetry *symmetry = SymmetryNew(G); CSymmetry *symmetry = SymmetryNew(G);
if(symmetry) { if(symmetry) {
tmp = PyObject_GetAttrString(model, "spacegroup"); tmp = PyObject_GetAttrString(model, "spacegroup");
if(tmp) { if(tmp) {
char *tmp_str = NULL; const char *tmp_str = NULL;
if(PConvPyStrToStrPtr(tmp, &tmp_str)) { if(PConvPyStrToStrPtr(tmp, &tmp_str)) {
UtilNCopy(symmetry->SpaceGroup, tmp_str, sizeof(WordType)); UtilNCopy(symmetry->SpaceGroup, tmp_str, sizeof(WordType));
} }
Py_DECREF(tmp); Py_DECREF(tmp);
} }
tmp = PyObject_GetAttrString(model, "cell"); tmp = PyObject_GetAttrString(model, "cell");
if(tmp) { if(tmp) {
float cell[6]; float cell[6];
if(PConvPyListToFloatArrayInPlace(tmp, cell, 6)) { if(PConvPyListToFloatArrayInPlace(tmp, cell, 6)) {
copy3f(cell, symmetry->Crystal->Dim); copy3f(cell, symmetry->Crystal->Dim);
skipping to change at line 7685 skipping to change at line 7692
connect_mode = tmp_int; connect_mode = tmp_int;
} }
Py_DECREF(tmp); Py_DECREF(tmp);
} }
} }
nAtom = cset->NIndex; nAtom = cset->NIndex;
} }
} }
/* include coordinate set */ /* include coordinate set */
if(ok) { if(ok) {
if(frame < 0)
frame = I->NCSet;
if(I->DiscreteFlag && atInfo) { if(I->DiscreteFlag && atInfo) {
unsigned int a; unsigned int a;
int fp1 = frame + 1; int fp1 = frame + 1;
AtomInfoType *ai = atInfo; AtomInfoType *ai = atInfo;
for(a = 0; a < nAtom; a++) { for(a = 0; a < nAtom; a++) {
(ai++)->discrete_state = fp1; (ai++)->discrete_state = fp1;
} }
} }
cset->Obj = I; cset->Obj = I;
cset->enumIndices(); cset->enumIndices();
cset->invalidateRep(cRepAll, cRepInvRep); cset->invalidateRep(cRepAll, cRepInvRep);
if(isNew) { if(isNew) {
I->AtomInfo = atInfo; /* IMPORTANT to reassign: this VLA may have move d! */ I->AtomInfo = atInfo; /* IMPORTANT to reassign: this VLA may have move d! */
} else { } else {
ObjectMoleculeMerge(I, atInfo, cset, false, cAIC_AllMask, true); /* NOTE: will release atInfo */ ObjectMoleculeMerge(I, atInfo, cset, false, cAIC_AllMask, true); /* NOTE: will release atInfo */
} }
if(isNew) if(isNew)
I->NAtom = nAtom; I->NAtom = nAtom;
if(frame < 0)
frame = I->NCSet;
VLACheck(I->CSet, CoordSet *, frame); VLACheck(I->CSet, CoordSet *, frame);
if(I->NCSet <= frame) if(I->NCSet <= frame)
I->NCSet = frame + 1; I->NCSet = frame + 1;
if(I->CSet[frame]) if(I->CSet[frame])
I->CSet[frame]->fFree(); I->CSet[frame]->fFree();
I->CSet[frame] = cset; I->CSet[frame] = cset;
if(fractional && cset->Symmetry && cset->Symmetry->Crystal) { if(fractional && cset->Symmetry && cset->Symmetry->Crystal) {
CrystalUpdate(cset->Symmetry->Crystal); CrystalUpdate(cset->Symmetry->Crystal);
CoordSetFracToReal(cset, cset->Symmetry->Crystal); CoordSetFracToReal(cset, cset->Symmetry->Crystal);
} }
skipping to change at line 8005 skipping to change at line 8012
ok = ErrMessage(G, "ReadMOLFile", "bad coordinate"); ok = ErrMessage(G, "ReadMOLFile", "bad coordinate");
} }
if(ok) { if(ok) {
p = ncopy(cc, p, 10); p = ncopy(cc, p, 10);
if(sscanf(cc, "%f", f++) != 1) if(sscanf(cc, "%f", f++) != 1)
ok = ErrMessage(G, "ReadMOLFile", "bad coordinate"); ok = ErrMessage(G, "ReadMOLFile", "bad coordinate");
} }
if(ok) { if(ok) {
p = nskip(p, 1); p = nskip(p, 1);
p = ntrim(cc, p, 3); p = ntrim(cc, p, 3);
strncpy(atInfo[a].elem, cc, cElemNameLen);
atInfo[a].name = LexIdx(G, cc); atInfo[a].name = LexIdx(G, cc);
atInfo[a].visRep = auto_show; atInfo[a].visRep = auto_show;
} }
if(ok) { if(ok) {
int tmp_int; int tmp_int;
p = nskip(p, 2); p = nskip(p, 2);
p = ncopy(cc, p, 3); p = ncopy(cc, p, 3);
if(sscanf(cc, "%hhi", &atInfo[a].formalCharge) == 1) { if(sscanf(cc, "%hhi", &atInfo[a].formalCharge) == 1) {
if(atInfo[a].formalCharge) { if(atInfo[a].formalCharge) {
atInfo[a].formalCharge = 4 - atInfo[a].formalCharge; atInfo[a].formalCharge = 4 - atInfo[a].formalCharge;
skipping to change at line 9548 skipping to change at line 9556
} }
if(inv_flag && cs) { if(inv_flag && cs) {
cs->invalidateRep(cRepAll, cRepInvRep); cs->invalidateRep(cRepAll, cRepInvRep);
} }
} }
} }
} }
break; break;
case OMOP_AddHydrogens: case OMOP_AddHydrogens:
if (ok) if (ok)
if (!op->i2)
ok &= ObjectMoleculeAddSeleHydrogensRefactored(I, sele, op->i1);
else
ok &= ObjectMoleculeAddSeleHydrogens(I, sele, -1); /* state? */ ok &= ObjectMoleculeAddSeleHydrogens(I, sele, -1); /* state? */
break; break;
case OMOP_FixHydrogens: case OMOP_FixHydrogens:
if (ok) if (ok)
ok &= ObjectMoleculeFixSeleHydrogens(I, sele, -1); /* state? */ ok &= ObjectMoleculeFixSeleHydrogens(I, sele, -1); /* state? */
break; break;
case OMOP_RevalenceFromSource: case OMOP_RevalenceFromSource:
case OMOP_RevalenceByGuessing: case OMOP_RevalenceByGuessing:
ai = I->AtomInfo; ai = I->AtomInfo;
for(a = 0; a < I->NAtom; a++) { for(a = 0; a < I->NAtom; a++) {
skipping to change at line 10371 skipping to change at line 10382
break; break;
case OMOP_FlagSet: case OMOP_FlagSet:
ai->flags |= op->i1; /* set flag */ ai->flags |= op->i1; /* set flag */
op->i3++; op->i3++;
break; break;
case OMOP_FlagClear: case OMOP_FlagClear:
ai->flags &= op->i2; /* clear flag */ ai->flags &= op->i2; /* clear flag */
op->i3++; op->i3++;
break; break;
case OMOP_VISI: case OMOP_VISI:
if(op->i1 < 0){ switch (op->i2) {
// show or hide all reps case cVis_HIDE:
ai->visRep = (op->i2) ? cRepBitmask : 0; ai->visRep &= ~(op->i1);
} else { I->Obj.visRep &= ~(op->i1); // cell
SET_BIT_TO(ai->visRep, op->i1, op->i2); break;
if(op->i1 == cRepCell) case cVis_SHOW:
SET_BIT_TO(I->Obj.visRep, cRepCell, op->i2); ai->visRep |= op->i1;
I->Obj.visRep |= op->i1; // cell
break;
case cVis_AS:
ai->visRep = op->i1;
I->Obj.visRep = op->i1; // cell
break;
} }
break; break;
break;
case OMOP_CheckVis: case OMOP_CheckVis:
if(GET_BIT(ai->visRep, op->i1)) { if((ai->visRep & op->i1)) {
op->i2 = true; op->i2 = true;
} }
break; break;
case OMOP_COLR: case OMOP_COLR:
if(op->i1 == cColorAtomic) if(op->i1 == cColorAtomic)
ai->color = AtomInfoGetColor(G, ai); ai->color = AtomInfoGetColor(G, ai);
else else
ai->color = op->i1; ai->color = op->i1;
hit_flag = true; hit_flag = true;
op->i2++; op->i2++;
skipping to change at line 10902 skipping to change at line 10918
} }
break; break;
} }
} }
switch (op->code) { switch (op->code) {
/* full coord-set based */ /* full coord-set based */
case OMOP_INVA: case OMOP_INVA:
/* shouldn't this be calling the object invalidation routine i nstead? */ /* shouldn't this be calling the object invalidation routine i nstead? */
if(inv_flag) { if(inv_flag) {
cs->objMolOpInvalidated = true; cs->objMolOpInvalidated = true;
if(op->i1 < 0) { for(d = 0; d < cRepCnt; d++) {
/* invalidate all representations */ if ((1 << d) & op->i1) {
for(d = 0; d < cRepCnt; d++) {
cs->invalidateRep(d, op->i2); cs->invalidateRep(d, op->i2);
} }
} else }
/* invalidate only that particular representation */
cs->invalidateRep(op->i1, op->i2);
} }
break; break;
} }
if(I->DiscreteFlag) { if(I->DiscreteFlag) {
/* don't iterate every coordinate set for discrete objects! */ /* don't iterate every coordinate set for discrete objects! */
break; break;
} }
} }
} /* end coordset section */ } /* end coordset section */
break; break;
skipping to change at line 11294 skipping to change at line 11307
} }
} }
PRINTFD(I->Obj.G, FB_ObjectMolecule) PRINTFD(I->Obj.G, FB_ObjectMolecule)
" ObjectMoleculeInvalidate: leaving...\n" ENDFD; " ObjectMoleculeInvalidate: leaving...\n" ENDFD;
} }
void ObjectMoleculeInvalidateAtomType(ObjectMolecule *I, int state){ void ObjectMoleculeInvalidateAtomType(ObjectMolecule *I, int state){
CoordSet *cset = 0; CoordSet *cset = 0;
int ai, atm, a; int ai, atm;
AtomInfoType *at; AtomInfoType *at;
cset = I->CSet[state]; cset = I->CSet[state];
a = state;
if (state < 0){ if (state < 0){
for (ai=0; ai < I->NAtom; ai++){ for (ai=0; ai < I->NAtom; ai++){
at = &I->AtomInfo[ai]; at = &I->AtomInfo[ai];
at->textType = 0; at->textType = 0;
} }
} else { } else {
for (ai=0; ai < cset->NIndex; ai++){ for (ai=0; ai < cset->NIndex; ai++){
atm = cset->IdxToAtm[ai]; atm = cset->IdxToAtm[ai];
if (atm>=0){ if (atm>=0){
at = &I->AtomInfo[ai]; at = &I->AtomInfo[ai];
skipping to change at line 11869 skipping to change at line 11881
/* ListInit(I->UndoData); */ /* ListInit(I->UndoData); */
for(a = 0; a <= cUndoMask; a++) for(a = 0; a <= cUndoMask; a++)
I->UndoCoord[a] = NULL; I->UndoCoord[a] = NULL;
I->CSet = VLACalloc(CoordSet *, I->NCSet); /* auto-zero */ I->CSet = VLACalloc(CoordSet *, I->NCSet); /* auto-zero */
for(a = 0; a < I->NCSet; a++) { for(a = 0; a < I->NCSet; a++) {
I->CSet[a] = CoordSetCopy(obj->CSet[a]); I->CSet[a] = CoordSetCopy(obj->CSet[a]);
if (I->CSet[a]) if (I->CSet[a])
I->CSet[a]->Obj = I; I->CSet[a]->Obj = I;
} }
if(obj->CSTmpl)
I->CSTmpl = CoordSetCopy(obj->CSTmpl);
if (obj->DiscreteFlag){ if (obj->DiscreteFlag){
int sz = VLAGetSize(obj->DiscreteAtmToIdx); int sz = VLAGetSize(obj->DiscreteAtmToIdx);
CoordSet *cs;
I->DiscreteAtmToIdx = VLACopy2(obj->DiscreteAtmToIdx); I->DiscreteAtmToIdx = VLACopy2(obj->DiscreteAtmToIdx);
I->DiscreteCSet = VLACalloc(CoordSet*, sz); I->DiscreteCSet = VLACalloc(CoordSet*, sz);
for(a = 0; a < obj->NCSet; a++) { I->updateAtmToIdx();
cs = const_cast<CoordSet*>(obj->CSet[a]);
if(cs) {
cs->tmp_index = a;
}
}
for(a = 0; a < obj->NAtom; a++) {
I->DiscreteCSet[a] = I->CSet[obj->DiscreteCSet[a]->tmp_index];
}
} }
if(obj->CSTmpl)
I->CSTmpl = CoordSetCopy(obj->CSTmpl);
else
I->CSTmpl = NULL;
I->Bond = VLACalloc(BondType, I->NBond); I->Bond = VLACalloc(BondType, I->NBond);
i0 = I->Bond; i0 = I->Bond;
i1 = obj->Bond; i1 = obj->Bond;
for(a = 0; a < I->NBond; a++) { for(a = 0; a < I->NBond; a++) {
AtomInfoBondCopy(G, i1++, i0++); AtomInfoBondCopy(G, i1++, i0++);
} }
I->AtomInfo = VLACalloc(AtomInfoType, I->NAtom); I->AtomInfo = VLACalloc(AtomInfoType, I->NAtom);
a0 = I->AtomInfo; a0 = I->AtomInfo;
a1 = obj->AtomInfo; a1 = obj->AtomInfo;
 End of changes. 39 change blocks. 
78 lines changed or deleted 81 lines changed or added

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