"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "layer4/Cmd.cpp" between
pymol-open-source-2.2.0.tar.gz and pymol-open-source-2.3.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.

Cmd.cpp  (pymol-open-source-2.2.0):Cmd.cpp  (pymol-open-source-2.3.0)
skipping to change at line 87 skipping to change at line 87
#include"TestPyMOL.h" #include"TestPyMOL.h"
#include"Color.h" #include"Color.h"
#include"Seq.h" #include"Seq.h"
#include"PyMOL.h" #include"PyMOL.h"
#include"Movie.h" #include"Movie.h"
#include"OVContext.h" #include"OVContext.h"
#include"PlugIOManager.h" #include"PlugIOManager.h"
#include"Seeker.h" #include"Seeker.h"
#include"ListMacros.h" #include"ListMacros.h"
#include"MacPyMOL.h" #include"MacPyMOL.h"
#include"ObjectAlignment.h"
#include "MovieScene.h" #include "MovieScene.h"
#include "CifFile.h" #include "CifFile.h"
#include "MoleculeExporter.h" #include "MoleculeExporter.h"
#define tmpSele "_tmp" #define tmpSele "_tmp"
#define tmpSele1 "_tmp1" #define tmpSele1 "_tmp1"
#define tmpSele2 "_tmp2" #define tmpSele2 "_tmp2"
skipping to change at line 116 skipping to change at line 117
#ifndef _PYMOL_EMBEDDED #ifndef _PYMOL_EMBEDDED
static int run_only_once = true; static int run_only_once = true;
#endif #endif
#endif #endif
#endif #endif
#define API_SETUP_PYMOL_GLOBALS \ #define API_SETUP_PYMOL_GLOBALS \
G = _api_get_pymol_globals(self) G = _api_get_pymol_globals(self)
/* /*
* C-level tests
*/
#ifdef _PYMOL_CTEST
#include "TestCmdTest2.h"
#else
static PyObject* CmdTest2(PyObject*, PyObject*)
{
PyErr_SetString(PyExc_NotImplementedError, "compile with --testing");
return nullptr;
}
#endif
/*
* Start a headless singleton instance in the current thread. * Start a headless singleton instance in the current thread.
* *
* Unlike when calling `pymol.finish_launching()`, there is no event loop, * Unlike when calling `pymol.finish_launching()`, there is no event loop,
* so animations, continuous sculpting and modal draw are not supported. * so animations, continuous sculpting and modal draw are not supported.
* *
* After calling this, SingletonPyMOLGlobals will be available. * After calling this, SingletonPyMOLGlobals will be available.
*/ */
static void launch_library_singleton() { static void launch_library_singleton() {
PyRun_SimpleString( PyRun_SimpleString(
"print(' PyMOL not running, entering library mode (experimental)')\n" "print(' PyMOL not running, entering library mode (experimental)')\n"
skipping to change at line 624 skipping to change at line 638
} else { } else {
API_HANDLE_ERROR; API_HANDLE_ERROR;
} }
if(ok && (ok = APIEnterBlockedNotModal(G))) { if(ok && (ok = APIEnterBlockedNotModal(G))) {
result = SelectorColorectionGet(G, prefix); result = SelectorColorectionGet(G, prefix);
APIExitBlocked(G); APIExitBlocked(G);
} }
return (APIAutoNone(result)); return (APIAutoNone(result));
} }
static PyObject *CmdSetRawAlignment(PyObject * self, PyObject * args)
{
PyMOLGlobals *G = nullptr;
const char *alnname;
const char *guidename;
PyObject *raw;
int state = 0, quiet = 1;
ObjectMolecule *guide = nullptr;
if(!PyArg_ParseTuple(args, "sOsii" "O",
&alnname, &raw, &guidename, &state, &quiet,
&self)) {
return nullptr;
}
API_SETUP_PYMOL_GLOBALS;
if(G == nullptr) {
PyErr_BadInternalCall();
return nullptr;
}
if (guidename[0]) {
guide = ExecutiveFindObjectMoleculeByName(G, guidename);
}
if(!PyList_Check(raw)) {
PyErr_SetString(PyExc_TypeError, "alignment must be list");
return nullptr;
}
auto n_cols = PyList_Size(raw);
pymol::vla<int> align_vla(n_cols * 3);
size_t vla_offset = 0;
for(size_t c = 0; c < n_cols; ++c) {
PyObject * col = PyList_GetItem(raw, c);
if(!PyList_Check(col)) {
PyErr_SetString(PyExc_TypeError, "columns must be list");
return nullptr;
}
auto n_idx = PyList_Size(col);
for(size_t i = 0; i < n_idx; ++i) {
const char * model;
int index;
PyObject * idx = PyList_GetItem(col, i);
if(!PyArg_ParseTuple(idx, "si", &model, &index)) {
PyErr_SetString(PyExc_TypeError, "indices must be (str, int)");
return nullptr;
}
ObjectMolecule * mol = ExecutiveFindObjectMoleculeByName(G, model);
if(!mol) {
PyErr_Format(PyExc_KeyError, "object '%s' not found", model);
return nullptr;
}
if (!guide) {
guide = mol;
}
if (index < 1 || mol->NAtom < index) {
PyErr_Format(PyExc_IndexError, "index ('%s', %d) out of range", model, i
ndex);
return nullptr;
}
auto uid = AtomInfoCheckUniqueID(G, mol->AtomInfo + index - 1);
*(align_vla.check(vla_offset++)) = uid;
}
*(align_vla.check(vla_offset++)) = 0;
}
align_vla.resize(vla_offset);
// does alignment object already exist?
auto cobj = ExecutiveFindObjectByName(G, alnname);
if (cobj && cobj->type != cObjectAlignment) {
ExecutiveDelete(G, cobj->Name);
cobj = nullptr;
}
// create alignment object
cobj = (CObject*) ObjectAlignmentDefine(G, (ObjectAlignment*) cobj,
align_vla.data(), state, true, guide, nullptr);
// manage alignment object
ObjectSetName(cobj, alnname);
ExecutiveManageObject(G, cobj, 0, quiet);
SceneInvalidate(G);
// make available as selection FIXME find better solution
cobj->update();
return APISuccess();
}
static PyObject* GetRawAlignment(PyMOLGlobals* G,
const ObjectAlignment* alnobj,
bool active_only,
int state)
{
if (state >= alnobj->NState) {
PyErr_Format(PyExc_IndexError, "state %d >= NState %d", state, alnobj->NStat
e);
return nullptr;
}
const auto& vla = alnobj->State[state].alignVLA;
if (!vla) {
PyErr_Format(PyExc_IndexError, "state %d not valid", state);
return nullptr;
}
auto hide_underscore = SettingGet<bool>(G, cSetting_hide_underscore_names);
const auto vla_len = VLAGetSize(vla);
PyObject * raw = PyList_New(0);
for (size_t i = 0; i < vla_len; ++i) {
PyObject * col = PyList_New(0);
for (int id; (id = vla[i]); ++i) {
auto eoo = ExecutiveUniqueIDAtomDictGet(G, id);
if (eoo
&& (!active_only || eoo->obj->Obj.Enabled)
&& (!hide_underscore || eoo->obj->Obj.Name[0] != '_')) {
PyObject * idx = Py_BuildValue("si", eoo->obj->Obj.Name, eoo->atm + 1);
PyList_Append(col, idx);
Py_DECREF(idx);
}
}
if (PyList_Size(col) > 0) {
PyList_Append(raw, col);
}
Py_DECREF(col);
}
return raw;
}
static PyObject *CmdGetRawAlignment(PyObject * self, PyObject * args) static PyObject *CmdGetRawAlignment(PyObject * self, PyObject * args)
{ {
PyMOLGlobals *G = NULL; PyMOLGlobals *G = NULL;
int ok = false; int ok = false;
char *name; const char *name;
int active_only; int active_only;
int state = 0;
PyObject *result = NULL; PyObject *result = NULL;
ok = PyArg_ParseTuple(args, "Osi", &self, &name, &active_only); ok = PyArg_ParseTuple(args, "Osi|i", &self, &name, &active_only, &state);
if(ok) { if(ok) {
API_SETUP_PYMOL_GLOBALS; API_SETUP_PYMOL_GLOBALS;
ok = (G != NULL); ok = (G != NULL);
} else { } else {
API_HANDLE_ERROR; API_HANDLE_ERROR;
} }
if(ok && (ok = APIEnterBlockedNotModal(G))) { if(ok && (ok = APIEnterBlockedNotModal(G))) {
int align_sele = -1; if (!name[0]) {
if(name[0]) { name = ExecutiveGetActiveAlignment(G);
}
if (name && name[0]) {
CObject *obj = ExecutiveFindObjectByName(G, name); CObject *obj = ExecutiveFindObjectByName(G, name);
if(obj->type == cObjectAlignment) { if (obj && obj->type == cObjectAlignment) {
align_sele = SelectorIndexByName(G, obj->Name); result = GetRawAlignment(G, (ObjectAlignment*) obj, active_only, state);
} else {
PyErr_Format(PyExc_KeyError, "no such alignment: '%s'", name);
} }
} else {
align_sele = ExecutiveGetActiveAlignmentSele(G);
}
if(align_sele >= 0) {
result = SeekerGetRawAlignment(G, align_sele, active_only);
} }
APIExitBlocked(G); APIExitBlocked(G);
} }
if(!result) { if(!result && !PyErr_Occurred()) {
return APIFailure(); return APIFailure();
} else } else
return result; return result;
} }
static PyObject *CmdGetOrigin(PyObject * self, PyObject * args) static PyObject *CmdGetOrigin(PyObject * self, PyObject * args)
{ {
PyMOLGlobals *G = NULL; PyMOLGlobals *G = NULL;
int ok = false; int ok = false;
float origin[3]; float origin[3];
skipping to change at line 4179 skipping to change at line 4342
PyMOLGlobals *G = NULL; PyMOLGlobals *G = NULL;
int ok = false; int ok = false;
ok = PyArg_ParseTuple(args, "O", &self); ok = PyArg_ParseTuple(args, "O", &self);
if(ok) { if(ok) {
API_SETUP_PYMOL_GLOBALS; API_SETUP_PYMOL_GLOBALS;
ok = (G != NULL); ok = (G != NULL);
} else { } else {
API_HANDLE_ERROR; API_HANDLE_ERROR;
} }
if(ok) { if(ok) {
MemoryDebugDump();
OVHeap_Dump(G->Context->heap, 0); OVHeap_Dump(G->Context->heap, 0);
SelectorMemoryDump(G); SelectorMemoryDump(G);
ExecutiveMemoryDump(G); ExecutiveMemoryDump(G);
} }
return APISuccess(); return APISuccess();
} }
static PyObject *Cmd_GetGlobalCObject(PyObject * self, PyObject * args) static PyObject *Cmd_GetGlobalCObject(PyObject * self, PyObject * args)
{ {
return PyCObject_FromVoidPtr((void *) &SingletonPyMOLGlobals, NULL); return PyCObject_FromVoidPtr((void *) &SingletonPyMOLGlobals, NULL);
skipping to change at line 4768 skipping to change at line 4930
ok = PyArg_ParseTuple(args, "O", &self); ok = PyArg_ParseTuple(args, "O", &self);
if(ok) { if(ok) {
API_SETUP_PYMOL_GLOBALS; API_SETUP_PYMOL_GLOBALS;
ok = (G != NULL); ok = (G != NULL);
} else { } else {
API_HANDLE_ERROR; API_HANDLE_ERROR;
} }
if(ok) { if(ok) {
if(G->Ready) { if(G->Ready) {
PyObject *result = NULL; PyObject *result = NULL;
OrthoLineType buffer;
int ok;
if(G->Terminating) { /* try to bail */ if(G->Terminating) { /* try to bail */
/* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ /* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */
#ifdef WIN32 #ifdef WIN32
abort(); abort();
#endif #endif
/* END PROPRIETARY CODE SEGMENT */ /* END PROPRIETARY CODE SEGMENT */
exit(0); exit(0);
} }
/* ALLOWED DURING MODAL DRAWING */ /* ALLOWED DURING MODAL DRAWING */
APIEnterBlocked(G); APIEnterBlocked(G);
ok = OrthoFeedbackOut(G, buffer); auto buffer = OrthoFeedbackOut(G, *G->Ortho);
APIExitBlocked(G); APIExitBlocked(G);
if(ok) if(!buffer.empty())
result = Py_BuildValue("s", buffer); result = Py_BuildValue("s", buffer.c_str());
return (APIAutoNone(result)); return (APIAutoNone(result));
} }
} }
return (APIAutoNone(NULL)); return (APIAutoNone(NULL));
} }
static PyObject *CmdGetSeqAlignStr(PyObject * self, PyObject * args) static PyObject *CmdGetSeqAlignStr(PyObject * self, PyObject * args)
{ {
PyMOLGlobals *G = NULL; PyMOLGlobals *G = NULL;
char *str1; char *str1;
skipping to change at line 4823 skipping to change at line 4983
result = Py_BuildValue("s", seq); result = Py_BuildValue("s", seq);
VLAFreeP(seq); VLAFreeP(seq);
} }
return (APIAutoNone(result)); return (APIAutoNone(result));
} }
static PyObject *CmdGetStr(PyObject * self, PyObject * args) static PyObject *CmdGetStr(PyObject * self, PyObject * args)
{ {
PyMOLGlobals *G = NULL; PyMOLGlobals *G = NULL;
PyObject *result = NULL; PyObject *result = NULL;
unique_vla_ptr<char> vla; pymol::vla<char> vla;
char *format; char *format;
char *sele; char *sele;
int state; int state;
char *ref; char *ref;
int ref_state; int ref_state;
int quiet; int quiet;
int multi; int multi;
ok_assert(1, PyArg_ParseTuple(args, "Ossisiii", &self, ok_assert(1, PyArg_ParseTuple(args, "Ossisiii", &self,
&format, &sele, &state, &ref, &ref_state, &multi, &quiet)); &format, &sele, &state, &ref, &ref_state, &multi, &quiet));
API_SETUP_PYMOL_GLOBALS; API_SETUP_PYMOL_GLOBALS;
ok_assert(1, G && APIEnterNotModal(G)); ok_assert(1, G && APIEnterNotModal(G));
vla = MoleculeExporterGetStr(G, format, sele, state, vla = MoleculeExporterGetStr(G, format, sele, state,
ref, ref_state, multi, quiet); ref, ref_state, multi, quiet);
ok_assert(2, vla); ok_assert(2, vla);
result = PyString_FromString(vla); result = PyBytes_FromStringAndSize(vla, VLAGetSize(vla));
ok_except2: ok_except2:
APIExit(G); APIExit(G);
return APIAutoNone(result); return APIAutoNone(result);
ok_except1: ok_except1:
API_HANDLE_ERROR; API_HANDLE_ERROR;
return APIAutoNone(NULL); return APIAutoNone(NULL);
} }
static PyObject *CmdGetModel(PyObject * self, PyObject * args) static PyObject *CmdGetModel(PyObject * self, PyObject * args)
skipping to change at line 4966 skipping to change at line 5126
static PyObject *CmdFitPairs(PyObject * self, PyObject * args) static PyObject *CmdFitPairs(PyObject * self, PyObject * args)
{ {
PyMOLGlobals *G = NULL; PyMOLGlobals *G = NULL;
PyObject *list; PyObject *list;
WordType *word = NULL; WordType *word = NULL;
int ln = 0; int ln = 0;
int a; int a;
PyObject *result = NULL; PyObject *result = NULL;
float valu = -1.0F; float valu = -1.0F;
int ok = false; int ok = false;
ok = PyArg_ParseTuple(args, "OO", &self, &list); int quiet = 0;
ok = PyArg_ParseTuple(args, "OOi", &self, &list, &quiet);
if(ok) { if(ok) {
API_SETUP_PYMOL_GLOBALS; API_SETUP_PYMOL_GLOBALS;
ok = (G != NULL); ok = (G != NULL);
} else { } else {
API_HANDLE_ERROR; API_HANDLE_ERROR;
} }
if(ok && (ok = APIEnterBlockedNotModal(G))) { if(ok && (ok = APIEnterBlockedNotModal(G))) {
ln = PyObject_Length(list); ln = PyObject_Length(list);
if(ln) { if(ln) {
if(ln & 0x1) if(ln & 0x1)
skipping to change at line 4992 skipping to change at line 5153
word = Alloc(WordType, ln); word = Alloc(WordType, ln);
a = 0; a = 0;
while(a < ln) { while(a < ln) {
PyObject * item = PySequence_GetItem(list, a); PyObject * item = PySequence_GetItem(list, a);
SelectorGetTmp(G, PyString_AsString(item), word[a]); SelectorGetTmp(G, PyString_AsString(item), word[a]);
Py_DECREF(item); Py_DECREF(item);
a++; a++;
} }
if((ok = APIEnterNotModal(G))) { if((ok = APIEnterNotModal(G))) {
valu = ExecutiveRMSPairs(G, word, ln / 2, 2); valu = ExecutiveRMSPairs(G, word, ln / 2, 2, quiet);
APIExit(G); APIExit(G);
} }
result = Py_BuildValue("f", valu); result = Py_BuildValue("f", valu);
for(a = 0; a < ln; a++) for(a = 0; a < ln; a++)
SelectorFreeTmp(G, word[a]); SelectorFreeTmp(G, word[a]);
FreeP(word); FreeP(word);
} }
APIExitBlocked(G); APIExitBlocked(G);
} }
return APIAutoNone(result); return APIAutoNone(result);
skipping to change at line 7188 skipping to change at line 7349
return APIFailure(); return APIFailure();
} }
static PyObject *CmdLoad(PyObject * self, PyObject * args) static PyObject *CmdLoad(PyObject * self, PyObject * args)
{ {
PyMOLGlobals *G = NULL; PyMOLGlobals *G = NULL;
char *fname, *oname; char *fname, *oname;
char *object_props = NULL; char *object_props = NULL;
char *atom_props = NULL; char *atom_props = NULL;
char *plugin = NULL; char *plugin = NULL;
int frame, type; int frame;
cLoadType_t type;
int finish, discrete; int finish, discrete;
int quiet; int quiet;
int ok = false; int ok = false;
int multiplex; int multiplex;
int zoom; int zoom;
int bytes; int bytes;
int mimic; int mimic;
ok = PyArg_ParseTuple(args, "Oss#iiiiiii|zzzi", &self, ok = PyArg_ParseTuple(args, "Oss#iiiiiii|zzzi", &self,
&oname, &fname, &bytes, &frame, &type, &oname, &fname, &bytes, &frame, &type,
&finish, &discrete, &quiet, &multiplex, &zoom, &finish, &discrete, &quiet, &multiplex, &zoom,
skipping to change at line 8539 skipping to change at line 8701
{"set", CmdSet, METH_VARARGS}, {"set", CmdSet, METH_VARARGS},
{"set_bond", CmdSetBond, METH_VARARGS}, {"set_bond", CmdSetBond, METH_VARARGS},
{"get_bond", CmdGetBond, METH_VARARGS}, {"get_bond", CmdGetBond, METH_VARARGS},
{"scene", CmdScene, METH_VARARGS}, {"scene", CmdScene, METH_VARARGS},
{"scene_order", CmdSceneOrder, METH_VARARGS}, {"scene_order", CmdSceneOrder, METH_VARARGS},
{"get_scene_order", CmdGetSceneOrder, METH_VARARGS}, {"get_scene_order", CmdGetSceneOrder, METH_VARARGS},
{"sculpt_deactivate", CmdSculptDeactivate, METH_VARARGS}, {"sculpt_deactivate", CmdSculptDeactivate, METH_VARARGS},
{"sculpt_activate", CmdSculptActivate, METH_VARARGS}, {"sculpt_activate", CmdSculptActivate, METH_VARARGS},
{"sculpt_iterate", CmdSculptIterate, METH_VARARGS}, {"sculpt_iterate", CmdSculptIterate, METH_VARARGS},
{"sculpt_purge", CmdSculptPurge, METH_VARARGS}, {"sculpt_purge", CmdSculptPurge, METH_VARARGS},
{"set_raw_alignment", CmdSetRawAlignment, METH_VARARGS},
{"set_busy", CmdSetBusy, METH_VARARGS}, {"set_busy", CmdSetBusy, METH_VARARGS},
{"set_colorection", CmdSetColorection, METH_VARARGS}, {"set_colorection", CmdSetColorection, METH_VARARGS},
{"set_colorection_name", CmdSetColorectionName, METH_VARARGS}, {"set_colorection_name", CmdSetColorectionName, METH_VARARGS},
{"set_dihe", CmdSetDihe, METH_VARARGS}, {"set_dihe", CmdSetDihe, METH_VARARGS},
{"set_discrete", CmdSetDiscrete, METH_VARARGS}, {"set_discrete", CmdSetDiscrete, METH_VARARGS},
{"set_feedback", CmdSetFeedbackMask, METH_VARARGS}, {"set_feedback", CmdSetFeedbackMask, METH_VARARGS},
{"set_frame", CmdSetFrame, METH_VARARGS}, {"set_frame", CmdSetFrame, METH_VARARGS},
{"set_name", CmdSetName, METH_VARARGS}, {"set_name", CmdSetName, METH_VARARGS},
{"set_geometry", CmdSetGeometry, METH_VARARGS}, {"set_geometry", CmdSetGeometry, METH_VARARGS},
{"set_matrix", CmdSetMatrix, METH_VARARGS}, {"set_matrix", CmdSetMatrix, METH_VARARGS},
skipping to change at line 8571 skipping to change at line 8734
{"smooth", CmdSmooth, METH_VARARGS}, {"smooth", CmdSmooth, METH_VARARGS},
{"sort", CmdSort, METH_VARARGS}, {"sort", CmdSort, METH_VARARGS},
{"spectrum", CmdSpectrum, METH_VARARGS}, {"spectrum", CmdSpectrum, METH_VARARGS},
{"spheroid", CmdSpheroid, METH_VARARGS}, {"spheroid", CmdSpheroid, METH_VARARGS},
{"splash", CmdSplash, METH_VARARGS}, {"splash", CmdSplash, METH_VARARGS},
{"stereo", CmdStereo, METH_VARARGS}, {"stereo", CmdStereo, METH_VARARGS},
{"system", CmdSystem, METH_VARARGS}, {"system", CmdSystem, METH_VARARGS},
{"symexp", CmdSymExp, METH_VARARGS}, {"symexp", CmdSymExp, METH_VARARGS},
{"symmetry_copy", CmdSymmetryCopy, METH_VARARGS}, {"symmetry_copy", CmdSymmetryCopy, METH_VARARGS},
{"test", CmdTest, METH_VARARGS}, {"test", CmdTest, METH_VARARGS},
{"test2", CmdTest2, METH_VARARGS},
{"toggle", CmdToggle, METH_VARARGS}, {"toggle", CmdToggle, METH_VARARGS},
{"matrix_copy", CmdMatrixCopy, METH_VARARGS}, {"matrix_copy", CmdMatrixCopy, METH_VARARGS},
{"transform_object", CmdTransformObject, METH_VARARGS}, {"transform_object", CmdTransformObject, METH_VARARGS},
{"transform_selection", CmdTransformSelection, METH_VARARGS}, {"transform_selection", CmdTransformSelection, METH_VARARGS},
{"translate_atom", CmdTranslateAtom, METH_VARARGS}, {"translate_atom", CmdTranslateAtom, METH_VARARGS},
{"translate_object_ttt", CmdTranslateObjectTTT, METH_VARARGS}, {"translate_object_ttt", CmdTranslateObjectTTT, METH_VARARGS},
{"turn", CmdTurn, METH_VARARGS}, {"turn", CmdTurn, METH_VARARGS},
{"viewport", CmdViewport, METH_VARARGS}, {"viewport", CmdViewport, METH_VARARGS},
{"vdw_fit", CmdVdwFit, METH_VARARGS}, {"vdw_fit", CmdVdwFit, METH_VARARGS},
{"volume", CmdVolume, METH_VARARGS}, {"volume", CmdVolume, METH_VARARGS},
 End of changes. 21 change blocks. 
23 lines changed or deleted 189 lines changed or added

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