PyMOL.cpp (pymol-v1.8.6.0.tar.bz2) | : | PyMOL.cpp (pymol-v2.1.0.tar.bz2) | ||
---|---|---|---|---|
skipping to change at line 21 | skipping to change at line 21 | |||
I* Additional authors of this source file include: | I* Additional authors of this source file include: | |||
-* | -* | |||
-* | -* | |||
-* | -* | |||
Z* ------------------------------------------------------------------- | Z* ------------------------------------------------------------------- | |||
*/ | */ | |||
#include"os_python.h" | #include"os_python.h" | |||
#include "os_std.h" | #include "os_std.h" | |||
#include "os_gl.h" | #include "os_gl.h" | |||
#include <clocale> | ||||
#include "MemoryDebug.h" | #include "MemoryDebug.h" | |||
#include "Base.h" | #include "Base.h" | |||
#include "OVContext.h" | #include "OVContext.h" | |||
#include "MemoryDebug.h" | #include "MemoryDebug.h" | |||
#include "MemoryCache.h" | #include "MemoryCache.h" | |||
#include "Err.h" | #include "Err.h" | |||
#include "Util.h" | #include "Util.h" | |||
skipping to change at line 139 | skipping to change at line 141 | |||
ObjectNameType ClickedObject; | ObjectNameType ClickedObject; | |||
int ClickedIndex, ClickedButton, ClickedModifiers, ClickedX, ClickedY, Clicked HavePos, ClickedPosState; | int ClickedIndex, ClickedButton, ClickedModifiers, ClickedX, ClickedY, Clicked HavePos, ClickedPosState; | |||
float ClickedPos[3]; | float ClickedPos[3]; | |||
int ImageRequestedFlag, ImageReadyFlag; | int ImageRequestedFlag, ImageReadyFlag; | |||
int DraggedFlag; | int DraggedFlag; | |||
int Reshape[PYMOL_RESHAPE_SIZE]; | int Reshape[PYMOL_RESHAPE_SIZE]; | |||
int Progress[PYMOL_PROGRESS_SIZE]; | int Progress[PYMOL_PROGRESS_SIZE]; | |||
int ProgressChanged; | int ProgressChanged; | |||
int IdleAndReady; | int IdleAndReady; | |||
int ExpireCount; | int ExpireCount; | |||
bool done_ConfigureShaders; | ||||
PyMOLModalDrawFn *ModalDraw; | PyMOLModalDrawFn *ModalDraw; | |||
PyMOLSwapBuffersFn *SwapFn; | PyMOLSwapBuffersFn *SwapFn; | |||
/* Python stuff */ | /* Python stuff */ | |||
#ifndef _PYMOL_NOPY | #ifndef _PYMOL_NOPY | |||
int PythonInitStage; | int PythonInitStage; | |||
#endif | #endif | |||
/* dynamically mapped string constants */ | /* dynamically mapped string constants */ | |||
skipping to change at line 200 | skipping to change at line 203 | |||
ov_word lex_but_drgo, lex_but_imsz, lex_but_imvz, lex_but_box, lex_but_irtz; | ov_word lex_but_drgo, lex_but_imsz, lex_but_imvz, lex_but_box, lex_but_irtz; | |||
OVOneToOne *MouseModeLexicon; | OVOneToOne *MouseModeLexicon; | |||
#include "buttonmodes_lex_def.h" | #include "buttonmodes_lex_def.h" | |||
OVOneToOne *PaletteLexicon; | OVOneToOne *PaletteLexicon; | |||
#include "palettes_lex_def.h" | #include "palettes_lex_def.h" | |||
#endif | #endif | |||
#ifndef _PYMOL_NOPY | ||||
AtomPropertyInfo AtomPropertyInfos[NUM_ATOM_PROPERTIES]; | AtomPropertyInfo AtomPropertyInfos[NUM_ATOM_PROPERTIES]; | |||
#endif | ||||
OVOneToOne *AtomPropertyLexicon; | OVOneToOne *AtomPropertyLexicon; | |||
ov_word lex_atom_prop_model, lex_atom_prop_index, lex_atom_prop_type, | ov_word lex_atom_prop_model, lex_atom_prop_index, lex_atom_prop_type, | |||
lex_atom_prop_name, lex_atom_prop_resn, lex_atom_prop_resi, | lex_atom_prop_name, lex_atom_prop_resn, lex_atom_prop_resi, | |||
lex_atom_prop_resv, lex_atom_prop_chain, lex_atom_prop_alt, | lex_atom_prop_resv, lex_atom_prop_chain, lex_atom_prop_alt, | |||
lex_atom_prop_segi, lex_atom_prop_elem, | lex_atom_prop_segi, lex_atom_prop_elem, | |||
lex_atom_prop_ss, lex_atom_prop_text_type, | lex_atom_prop_ss, lex_atom_prop_text_type, | |||
lex_atom_prop_custom, lex_atom_prop_label, lex_atom_prop_numeric_type, | lex_atom_prop_custom, lex_atom_prop_label, lex_atom_prop_numeric_type, | |||
lex_atom_prop_q, lex_atom_prop_b, lex_atom_prop_vdw, | lex_atom_prop_q, lex_atom_prop_b, lex_atom_prop_vdw, | |||
lex_atom_prop_elec_radius, lex_atom_prop_partial_charge, lex_atom_prop_forma l_charge, | lex_atom_prop_elec_radius, lex_atom_prop_partial_charge, lex_atom_prop_forma l_charge, | |||
lex_atom_prop_stereo, lex_atom_prop_cartoon, lex_atom_prop_color, | lex_atom_prop_stereo, lex_atom_prop_cartoon, lex_atom_prop_color, | |||
lex_atom_prop_ID, lex_atom_prop_rank, lex_atom_prop_flags, | lex_atom_prop_ID, lex_atom_prop_rank, lex_atom_prop_flags, | |||
lex_atom_prop_geom, lex_atom_prop_valence, | lex_atom_prop_geom, lex_atom_prop_valence, | |||
lex_atom_prop_x, lex_atom_prop_y, lex_atom_prop_z, | lex_atom_prop_x, lex_atom_prop_y, lex_atom_prop_z, | |||
lex_atom_prop_settings, lex_atom_prop_properties, | lex_atom_prop_settings, lex_atom_prop_properties, | |||
lex_atom_prop_reps, | lex_atom_prop_reps, | |||
lex_atom_prop_protons, | lex_atom_prop_protons, | |||
lex_atom_prop_oneletter, | ||||
lex_atom_prop_s, lex_atom_prop_p, lex_atom_prop_state; | lex_atom_prop_s, lex_atom_prop_p, lex_atom_prop_state; | |||
/* | /* | |||
lex_atom_prop_, lex_atom_prop_, lex_atom_prop_, | lex_atom_prop_, lex_atom_prop_, lex_atom_prop_, | |||
lex_atom_prop_, lex_atom_prop_, lex_atom_prop_,*/ | lex_atom_prop_, lex_atom_prop_, lex_atom_prop_,*/ | |||
} _CPyMOL; | } _CPyMOL; | |||
/* convenience functions -- inline */ | /* convenience functions -- inline */ | |||
#ifdef _PYMOL_INLINE | #ifdef _PYMOL_INLINE | |||
skipping to change at line 336 | skipping to change at line 338 | |||
return_OVstatus_FAILURE \ | return_OVstatus_FAILURE \ | |||
else \ | else \ | |||
I -> lex_ ## NAME = result.word;} \ | I -> lex_ ## NAME = result.word;} \ | |||
if(!OVreturn_IS_OK( OVOneToOne_Set(I->Reinit,I->lex_ ## NAME, CODE))) \ | if(!OVreturn_IS_OK( OVOneToOne_Set(I->Reinit,I->lex_ ## NAME, CODE))) \ | |||
return_OVstatus_FAILURE; | return_OVstatus_FAILURE; | |||
I->Reinit = OVOneToOne_New(C->heap); | I->Reinit = OVOneToOne_New(C->heap); | |||
if(!I->Reinit) | if(!I->Reinit) | |||
return_OVstatus_FAILURE; | return_OVstatus_FAILURE; | |||
if(!OVreturn_IS_OK(OVOneToOne_Set(I->Reinit, I->lex_everything, 0))) | LEX_REINIT(everything, 0); | |||
return_OVstatus_FAILURE; | ||||
LEX_REINIT(settings, 1); | LEX_REINIT(settings, 1); | |||
#define LEX_SELLIST(NAME,CODE) {if(!OVreturn_IS_OK( (result= OVLexicon_GetFromCS tring(I->Lex,#NAME)))) \ | #define LEX_SELLIST(NAME,CODE) {if(!OVreturn_IS_OK( (result= OVLexicon_GetFromCS tring(I->Lex,#NAME)))) \ | |||
return_OVstatus_FAILURE \ | return_OVstatus_FAILURE \ | |||
else \ | else \ | |||
I -> lex_ ## NAME = result.word;} \ | I -> lex_ ## NAME = result.word;} \ | |||
if(!OVreturn_IS_OK( OVOneToOne_Set(I->SelectList,I->lex_ ## NAME, CODE))) \ | if(!OVreturn_IS_OK( OVOneToOne_Set(I->SelectList,I->lex_ ## NAME, CODE))) \ | |||
return_OVstatus_FAILURE; | return_OVstatus_FAILURE; | |||
I->SelectList = OVOneToOne_New(C->heap); | I->SelectList = OVOneToOne_New(C->heap); | |||
skipping to change at line 550 | skipping to change at line 551 | |||
#define LEX_ATOM_PROP_S(NAME,CODE,TYPE,OFFSET,MAXLEN) LEX_ATM_PROP(NAME) \ | #define LEX_ATOM_PROP_S(NAME,CODE,TYPE,OFFSET,MAXLEN) LEX_ATM_PROP(NAME) \ | |||
if(!OVreturn_IS_OK( OVOneToOne_Set(I->AtomPropertyLexicon,I->lex_atom_prop_ ## NAME, CODE))) \ | if(!OVreturn_IS_OK( OVOneToOne_Set(I->AtomPropertyLexicon,I->lex_atom_prop_ ## NAME, CODE))) \ | |||
return_OVstatus_FAILURE; \ | return_OVstatus_FAILURE; \ | |||
I->AtomPropertyInfos[CODE].id = CODE; \ | I->AtomPropertyInfos[CODE].id = CODE; \ | |||
I->AtomPropertyInfos[CODE].Ptype = TYPE; \ | I->AtomPropertyInfos[CODE].Ptype = TYPE; \ | |||
I->AtomPropertyInfos[CODE].offset = OFFSET; \ | I->AtomPropertyInfos[CODE].offset = OFFSET; \ | |||
I->AtomPropertyInfos[CODE].maxlen = MAXLEN; | I->AtomPropertyInfos[CODE].maxlen = MAXLEN; | |||
/*TEMP*/ | /*TEMP*/ | |||
#ifndef _PYMOL_NOPY | ||||
LEX_ATOM_PROP(model, 0, cPType_model, 0); | LEX_ATOM_PROP(model, 0, cPType_model, 0); | |||
LEX_ATOM_PROP(index, 1, cPType_index, 0); | LEX_ATOM_PROP(index, 1, cPType_index, 0); | |||
LEX_ATOM_PROP(type, 2, cPType_char_as_type, 0); | LEX_ATOM_PROP(type, 2, cPType_char_as_type, 0); | |||
LEX_ATOM_PROP(name, 3, cPType_int_as_string, offsetof(AtomInfoType,name)); | LEX_ATOM_PROP(name, 3, cPType_int_as_string, offsetof(AtomInfoType,name)); | |||
LEX_ATOM_PROP(resn, 4, cPType_int_as_string, offsetof(AtomInfoType,resn)); | LEX_ATOM_PROP(resn, 4, cPType_int_as_string, offsetof(AtomInfoType,resn)); | |||
LEX_ATOM_PROP(resi, 5, 0, 0); | LEX_ATOM_PROP(resi, 5, 0, 0); | |||
LEX_ATOM_PROP(resv, 6, cPType_int, offsetof(AtomInfoType,resv)); | LEX_ATOM_PROP(resv, 6, cPType_int, offsetof(AtomInfoType,resv)); | |||
LEX_ATOM_PROP(chain, 7, cPType_int_as_string, offsetof(AtomInfoType,chain)); | LEX_ATOM_PROP(chain, 7, cPType_int_as_string, offsetof(AtomInfoType,chain)); | |||
LEX_ATOM_PROP_S(alt, 8, cPType_string, offsetof(AtomInfoType,alt), 1); | LEX_ATOM_PROP_S(alt, 8, cPType_string, offsetof(AtomInfoType,alt), 1); | |||
LEX_ATOM_PROP(segi, 9, cPType_int_as_string, offsetof(AtomInfoType,segi)); | LEX_ATOM_PROP(segi, 9, cPType_int_as_string, offsetof(AtomInfoType,segi)); | |||
skipping to change at line 591 | skipping to change at line 591 | |||
LEX_ATOM_PROP(x, 30, cPType_xyz_float, 0); | LEX_ATOM_PROP(x, 30, cPType_xyz_float, 0); | |||
LEX_ATOM_PROP(y, 31, cPType_xyz_float, 1); | LEX_ATOM_PROP(y, 31, cPType_xyz_float, 1); | |||
LEX_ATOM_PROP(z, 32, cPType_xyz_float, 2); | LEX_ATOM_PROP(z, 32, cPType_xyz_float, 2); | |||
LEX_ATOM_PROP(settings, 33, cPType_settings, 0); | LEX_ATOM_PROP(settings, 33, cPType_settings, 0); | |||
LEX_ATOM_PROP(properties, 34, cPType_properties, 0); | LEX_ATOM_PROP(properties, 34, cPType_properties, 0); | |||
LEX_ATOM_PROP(s, 35, cPType_settings, 0); | LEX_ATOM_PROP(s, 35, cPType_settings, 0); | |||
LEX_ATOM_PROP(p, 36, cPType_properties, 0); | LEX_ATOM_PROP(p, 36, cPType_properties, 0); | |||
LEX_ATOM_PROP(state, 37, cPType_state, 0); | LEX_ATOM_PROP(state, 37, cPType_state, 0); | |||
LEX_ATOM_PROP(reps, 38, cPType_int, offsetof(AtomInfoType, visRep)); | LEX_ATOM_PROP(reps, 38, cPType_int, offsetof(AtomInfoType, visRep)); | |||
LEX_ATOM_PROP(protons, 39, cPType_schar, offsetof(AtomInfoType, protons)); | LEX_ATOM_PROP(protons, 39, cPType_schar, offsetof(AtomInfoType, protons)); | |||
LEX_ATOM_PROP(oneletter, 40, 0, 0); | ||||
// LEX_ATOM_PROP(, ); | // LEX_ATOM_PROP(, ); | |||
#endif | ||||
return_OVstatus_SUCCESS; | return_OVstatus_SUCCESS; | |||
} | } | |||
int PyMOL_NewG3DStream(CPyMOL * I, int **array_ptr) | int PyMOL_NewG3DStream(CPyMOL * I, int **array_ptr) | |||
{ | { | |||
int *return_vla = ExecutiveGetG3d(I->G); | int *return_vla = ExecutiveGetG3d(I->G); | |||
int result = OVstatus_FAILURE; | int result = OVstatus_FAILURE; | |||
if(return_vla) { | if(return_vla) { | |||
result = VLAGetSize(return_vla) * (sizeof(G3dPrimitive) / sizeof(int)); | result = VLAGetSize(return_vla) * (sizeof(G3dPrimitive) / sizeof(int)); | |||
} | } | |||
skipping to change at line 744 | skipping to change at line 745 | |||
result.array[a + 12] = tmp[a + 19]; | result.array[a + 12] = tmp[a + 19]; | |||
result.array[a + 15] = tmp[a + 22]; | result.array[a + 15] = tmp[a + 22]; | |||
} | } | |||
result.status = get_status_ok(true); | result.status = get_status_ok(true); | |||
} else { | } else { | |||
result.status = get_status_ok(false); | result.status = get_status_ok(false); | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_float_array PyMOL_CmdAlign(CPyMOL * I, char *source, char *target, | PyMOLreturn_float_array PyMOL_CmdAlign(CPyMOL * I, const char *source, const cha r *target, | |||
float cutoff, int cycles, float gap, floa t extend, | float cutoff, int cycles, float gap, floa t extend, | |||
int max_gap, char *object, char *matrix, | int max_gap, const char *object, const ch ar *matrix, | |||
int source_state, int target_state, int q uiet, | int source_state, int target_state, int q uiet, | |||
int max_skip, int transform, int reset) | int max_skip, int transform, int reset) | |||
{ | { | |||
PyMOLreturn_float_array result = { PyMOLstatus_FAILURE }; | PyMOLreturn_float_array result = { PyMOLstatus_FAILURE }; | |||
PYMOL_API_LOCK OrthoLineType s2 = "", s3 = ""; | PYMOL_API_LOCK OrthoLineType s2 = "", s3 = ""; | |||
int ok = false; | int ok = false; | |||
ExecutiveRMSInfo rms_info; | ExecutiveRMSInfo rms_info; | |||
result.size = 7; | result.size = 7; | |||
result.array = VLAlloc(float, result.size); | result.array = VLAlloc(float, result.size); | |||
if(!result.array) { | if(!result.array) { | |||
skipping to change at line 886 | skipping to change at line 887 | |||
} | } | |||
static OVreturn_word get_reinit_id(CPyMOL * I, const char *reinit) | static OVreturn_word get_reinit_id(CPyMOL * I, const char *reinit) | |||
{ | { | |||
OVreturn_word result; | OVreturn_word result; | |||
if(!OVreturn_IS_OK((result = OVLexicon_BorrowFromCString(I->Lex, reinit)))) | if(!OVreturn_IS_OK((result = OVLexicon_BorrowFromCString(I->Lex, reinit)))) | |||
return result; | return result; | |||
return OVOneToOne_GetForward(I->Reinit, result.word); | return OVOneToOne_GetForward(I->Reinit, result.word); | |||
} | } | |||
static OVreturn_word get_select_list_mode(CPyMOL * I, char *mode) | static OVreturn_word get_select_list_mode(CPyMOL * I, const char *mode) | |||
{ | { | |||
OVreturn_word result; | OVreturn_word result; | |||
if(!OVreturn_IS_OK((result = OVLexicon_BorrowFromCString(I->Lex, mode)))) | if(!OVreturn_IS_OK((result = OVLexicon_BorrowFromCString(I->Lex, mode)))) | |||
return result; | return result; | |||
return OVOneToOne_GetForward(I->SelectList, result.word); | return OVOneToOne_GetForward(I->SelectList, result.word); | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdClip(CPyMOL * I, | PyMOLreturn_status PyMOL_CmdClip(CPyMOL * I, | |||
const char *mode, float amount, | const char *mode, float amount, | |||
const char *selection, | const char *selection, | |||
skipping to change at line 910 | skipping to change at line 911 | |||
PYMOL_API_LOCK OrthoLineType s1; | PYMOL_API_LOCK OrthoLineType s1; | |||
OVreturn_word clip_id; | OVreturn_word clip_id; | |||
if(OVreturn_IS_OK((clip_id = get_clip_id(I, mode)))) { | if(OVreturn_IS_OK((clip_id = get_clip_id(I, mode)))) { | |||
SelectorGetTmp2(I->G, selection, s1); | SelectorGetTmp2(I->G, selection, s1); | |||
SceneClip(I->G, clip_id.word, amount, s1, state - 1); | SceneClip(I->G, clip_id.word, amount, s1, state - 1); | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
} | } | |||
PYMOL_API_UNLOCK return return_status_ok(ok); | PYMOL_API_UNLOCK return return_status_ok(ok); | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdLabel(CPyMOL * I, char *selection, char *text, int q uiet) | PyMOLreturn_status PyMOL_CmdLabel(CPyMOL * I, const char *selection, const char *text, int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PYMOL_API_LOCK OrthoLineType s1; | PYMOL_API_LOCK OrthoLineType s1; | |||
SelectorGetTmp(I->G, selection, s1); | SelectorGetTmp(I->G, selection, s1); | |||
ok = ExecutiveLabel(I->G, s1, text, quiet, cExecutiveLabelEvalAlt); | ok = ExecutiveLabel(I->G, s1, text, quiet, cExecutiveLabelEvalAlt); | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
PYMOL_API_UNLOCK return return_status_ok(ok); | PYMOL_API_UNLOCK return return_status_ok(ok); | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdSelect(CPyMOL * I, char *name, char *selection, int quiet) | PyMOLreturn_status PyMOL_CmdSelect(CPyMOL * I, const char *name, const char *sel ection, int quiet) | |||
{ | { | |||
int ok = true; | int ret = -1; | |||
PYMOL_API_LOCK ok = SelectorCreate(I->G, name, selection, NULL, quiet, NULL); | PYMOL_API_LOCK ret = SelectorCreate(I->G, name, selection, NULL, quiet, NULL); | |||
PYMOL_API_UNLOCK return return_status_ok(ok); | PYMOL_API_UNLOCK return return_status_ok(ret >= 0); // if ret is negative it s | |||
hould fail | ||||
} | } | |||
PyMOLreturn_status PyMOL_CmdSelectList(CPyMOL * I, char *name, char *object, int | PyMOLreturn_status PyMOL_CmdSelectList(CPyMOL * I, const char *name, const char | |||
*list, | *object, int *list, | |||
int list_len, int state, char *mode, int | int list_len, int state, const char *mode | |||
quiet) | , int quiet) | |||
{ | { | |||
PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | |||
PYMOL_API_LOCK OVreturn_word mode_id; | PYMOL_API_LOCK OVreturn_word mode_id; | |||
if(OVreturn_IS_OK((mode_id = get_select_list_mode(I, mode)))) { | if(OVreturn_IS_OK((mode_id = get_select_list_mode(I, mode)))) { | |||
result.status = | result.status = | |||
ExecutiveSelectList(I->G, name, object, list, list_len, state - 1, mode_id .word, | ExecutiveSelectList(I->G, name, object, list, list_len, state - 1, mode_id .word, | |||
quiet); | quiet); | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
skipping to change at line 1014 | skipping to change at line 1015 | |||
ok = (SelectorGetTmp2(I->G, name, s1) >= 0); | ok = (SelectorGetTmp2(I->G, name, s1) >= 0); | |||
if(ok) | if(ok) | |||
ok = ExecutiveSetOnOffBySele(I->G, s1, false); | ok = ExecutiveSetOnOffBySele(I->G, s1, false); | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
} else { | } else { | |||
ok = ExecutiveSetObjVisib(I->G, name, false, false); | ok = ExecutiveSetObjVisib(I->G, name, false, false); | |||
} | } | |||
PYMOL_API_UNLOCK return return_status_ok(ok); | PYMOL_API_UNLOCK return return_status_ok(ok); | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdSetBond(CPyMOL * I, char *setting, char *value, | PyMOLreturn_status PyMOL_CmdSetBond(CPyMOL * I, const char *setting, const char | |||
char *selection1, char *selection2, | *value, | |||
const char *selection1, const char *selectio | ||||
n2, | ||||
int state, int quiet, int side_effects) | int state, int quiet, int side_effects) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PYMOL_API_LOCK { | PYMOL_API_LOCK { | |||
OVreturn_word setting_id; | OVreturn_word setting_id; | |||
OrthoLineType s1 = ""; | OrthoLineType s1 = ""; | |||
OrthoLineType s2 = ""; | OrthoLineType s2 = ""; | |||
if(ok) ok = OVreturn_IS_OK((setting_id = get_setting_id(I, setting))); | if(ok) ok = OVreturn_IS_OK((setting_id = get_setting_id(I, setting))); | |||
if(ok) ok = (SelectorGetTmp(I->G, selection1, s1) >= 0); | if(ok) ok = (SelectorGetTmp(I->G, selection1, s1) >= 0); | |||
if(ok) { | if(ok) { | |||
skipping to change at line 1043 | skipping to change at line 1044 | |||
ok = ExecutiveSetBondSettingFromString(I->G, setting_id.word, value, | ok = ExecutiveSetBondSettingFromString(I->G, setting_id.word, value, | |||
s1, s2, | s1, s2, | |||
state - 1, quiet, side_effects); | state - 1, quiet, side_effects); | |||
} | } | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
SelectorFreeTmp(I->G, s2); | SelectorFreeTmp(I->G, s2); | |||
} PYMOL_API_UNLOCK | } PYMOL_API_UNLOCK | |||
return return_status_ok(ok); | return return_status_ok(ok); | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdUnsetBond(CPyMOL * I, char *setting, | PyMOLreturn_status PyMOL_CmdUnsetBond(CPyMOL * I, const char *setting, | |||
char *selection1, char *selection2, | const char *selection1, const char *select | |||
ion2, | ||||
int state, int quiet, int side_effects) | int state, int quiet, int side_effects) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PYMOL_API_LOCK { | PYMOL_API_LOCK { | |||
OVreturn_word setting_id; | OVreturn_word setting_id; | |||
OrthoLineType s1 = ""; | OrthoLineType s1 = ""; | |||
OrthoLineType s2 = ""; | OrthoLineType s2 = ""; | |||
if(ok) ok = OVreturn_IS_OK((setting_id = get_setting_id(I, setting))); | if(ok) ok = OVreturn_IS_OK((setting_id = get_setting_id(I, setting))); | |||
if(ok) ok = (SelectorGetTmp(I->G, selection1, s1) >= 0); | if(ok) ok = (SelectorGetTmp(I->G, selection1, s1) >= 0); | |||
if(ok) { | if(ok) { | |||
skipping to change at line 1116 | skipping to change at line 1117 | |||
if(ok) { | if(ok) { | |||
ExecutiveGetSettingFromString(I->G, &result, setting_id.word, s1, | ExecutiveGetSettingFromString(I->G, &result, setting_id.word, s1, | |||
state - 1, quiet); | state - 1, quiet); | |||
} | } | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdUnset(CPyMOL * I, char *setting, char *selection, | PyMOLreturn_status PyMOL_CmdUnset(CPyMOL * I, const char *setting, const char *s election, | |||
int state, int quiet, int side_effects) | int state, int quiet, int side_effects) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PYMOL_API_LOCK { | PYMOL_API_LOCK { | |||
OVreturn_word setting_id; | OVreturn_word setting_id; | |||
OrthoLineType s1 = ""; | OrthoLineType s1 = ""; | |||
if(ok) ok = OVreturn_IS_OK((setting_id = get_setting_id(I, setting))); | if(ok) ok = OVreturn_IS_OK((setting_id = get_setting_id(I, setting))); | |||
if(ok) ok = (SelectorGetTmp2(I->G, selection, s1) >= 0); | if(ok) ok = (SelectorGetTmp2(I->G, selection, s1) >= 0); | |||
if(ok) { | if(ok) { | |||
ExecutiveUnsetSetting(I->G, setting_id.word, s1, | ExecutiveUnsetSetting(I->G, setting_id.word, s1, | |||
state - 1, quiet, side_effects); | state - 1, quiet, side_effects); | |||
} | } | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
} | } | |||
PYMOL_API_UNLOCK return return_status_ok(ok); | PYMOL_API_UNLOCK return return_status_ok(ok); | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdColor(CPyMOL * I, char *color, char *selection, int flags, | PyMOLreturn_status PyMOL_CmdColor(CPyMOL * I, const char *color, const char *sel ection, int flags, | |||
int quiet) | int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PYMOL_API_LOCK OrthoLineType s1 = ""; | PYMOL_API_LOCK OrthoLineType s1 = ""; | |||
SelectorGetTmp2(I->G, selection, s1); | SelectorGetTmp2(I->G, selection, s1); | |||
ok = ExecutiveColor(I->G, s1, color, flags, quiet); | ok = ExecutiveColor(I->G, s1, color, flags, quiet); | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
PYMOL_API_UNLOCK return return_status_ok(ok); | PYMOL_API_UNLOCK return return_status_ok(ok); | |||
} | } | |||
skipping to change at line 1188 | skipping to change at line 1189 | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
if(ok) { | if(ok) { | |||
result.value = MovieGetLength(I->G); | result.value = MovieGetLength(I->G); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
}; | }; | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_float PyMOL_CmdGetDistance(CPyMOL * I, | PyMOLreturn_float PyMOL_CmdGetDistance(CPyMOL * I, | |||
char *selection1, | const char *selection1, | |||
char *selection2, int state, int quiet) | const char *selection2, int state, int qu | |||
iet) | ||||
{ | { | |||
int ok = true; | int ok = true; | |||
PyMOLreturn_float result; | PyMOLreturn_float result; | |||
PYMOL_API_LOCK { | PYMOL_API_LOCK { | |||
ok = ExecutiveGetDistance(I->G, | ok = ExecutiveGetDistance(I->G, | |||
selection1, | selection1, | |||
selection2, | selection2, | |||
&result.value, state); | &result.value, state); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_float PyMOL_CmdDistance(CPyMOL * I, | PyMOLreturn_float PyMOL_CmdDistance(CPyMOL * I, | |||
char *name, | const char *name, | |||
char *selection1, | const char *selection1, | |||
char *selection2, | const char *selection2, | |||
int mode, | int mode, | |||
float cutoff, | float cutoff, | |||
int label, int reset, int zoom, int state, i nt quiet) | int label, int reset, int zoom, int state, i nt quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PyMOLreturn_float result; | PyMOLreturn_float result; | |||
PYMOL_API_LOCK { | PYMOL_API_LOCK { | |||
ok = ExecutiveDist(I->G, &result.value, name, | ok = ExecutiveDist(I->G, &result.value, name, | |||
selection1, | selection1, | |||
selection2, | selection2, | |||
mode, cutoff, label, quiet, reset, state, zoom); | mode, cutoff, label, quiet, reset, state, zoom); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_float PyMOL_CmdGetAngle(CPyMOL * I, | PyMOLreturn_float PyMOL_CmdGetAngle(CPyMOL * I, | |||
char *selection1, | const char *selection1, | |||
char *selection2, | const char *selection2, | |||
char *selection3, int state, int quiet) | const char *selection3, int state, int quiet | |||
) | ||||
{ | { | |||
int ok = true; | int ok = true; | |||
PyMOLreturn_float result; | PyMOLreturn_float result; | |||
PYMOL_API_LOCK { | PYMOL_API_LOCK { | |||
ok = ExecutiveGetAngle(I->G, | ok = ExecutiveGetAngle(I->G, | |||
selection1, | selection1, | |||
selection2, | selection2, | |||
selection3, | selection3, | |||
&result.value, state); | &result.value, state); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_float PyMOL_CmdAngle(CPyMOL * I, | PyMOLreturn_float PyMOL_CmdAngle(CPyMOL * I, | |||
char *name, | const char *name, | |||
char *selection1, | const char *selection1, | |||
char *selection2, | const char *selection2, | |||
char *selection3, | const char *selection3, | |||
int mode, | int mode, | |||
int label, int reset, int zoom, int state, int quiet) | int label, int reset, int zoom, int state, int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PyMOLreturn_float result; | PyMOLreturn_float result; | |||
PYMOL_API_LOCK { | PYMOL_API_LOCK { | |||
ok = ExecutiveAngle(I->G, &result.value, name, | ok = ExecutiveAngle(I->G, &result.value, name, | |||
selection1, | selection1, | |||
selection2, | selection2, | |||
selection3, | selection3, | |||
mode, label, reset, zoom, quiet, state); | mode, label, reset, zoom, quiet, state); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_float PyMOL_CmdGetDihedral(CPyMOL * I, | PyMOLreturn_float PyMOL_CmdGetDihedral(CPyMOL * I, | |||
char *selection1, | const char *selection1, | |||
char *selection2, | const char *selection2, | |||
char *selection3, | const char *selection3, | |||
char *selection4, int state, int quiet) | const char *selection4, int state, int qu | |||
iet) | ||||
{ | { | |||
int ok = true; | int ok = true; | |||
PyMOLreturn_float result; | PyMOLreturn_float result; | |||
PYMOL_API_LOCK { | PYMOL_API_LOCK { | |||
ok = ExecutiveGetDihe(I->G, | ok = ExecutiveGetDihe(I->G, | |||
selection1, | selection1, | |||
selection2, | selection2, | |||
selection3, | selection3, | |||
selection4, | selection4, | |||
&result.value, state); | &result.value, state); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_float PyMOL_CmdDihedral(CPyMOL * I, | PyMOLreturn_float PyMOL_CmdDihedral(CPyMOL * I, | |||
char *name, | const char *name, | |||
char *selection1, | const char *selection1, | |||
char *selection2, | const char *selection2, | |||
char *selection3, | const char *selection3, | |||
char *selection4, | const char *selection4, | |||
int mode, | int mode, | |||
int label, int reset, int zoom, int state, i nt quiet) | int label, int reset, int zoom, int state, i nt quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PyMOLreturn_float result; | PyMOLreturn_float result; | |||
PYMOL_API_LOCK { | PYMOL_API_LOCK { | |||
ExecutiveDihedral(I->G, &result.value, name, | ExecutiveDihedral(I->G, &result.value, name, | |||
selection1, | selection1, | |||
selection2, | selection2, | |||
selection3, | selection3, | |||
selection4, | selection4, | |||
mode, label, reset, zoom, quiet, state); | mode, label, reset, zoom, quiet, state); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdIsodot(CPyMOL * I, char *name, char *map_name, float | PyMOLreturn_status PyMOL_CmdIsodot(CPyMOL * I, const char *name, const char *map | |||
level, | _name, float level, | |||
char *selection, float buffer, int state, flo | const char *selection, float buffer, int stat | |||
at carve, | e, float carve, | |||
int source_state, int quiet) | int source_state, int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
OrthoLineType s1 = ""; | OrthoLineType s1 = ""; | |||
PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | |||
int box_mode = 0; | int box_mode = 0; | |||
PYMOL_API_LOCK if(selection && selection[0]) { | PYMOL_API_LOCK if(selection && selection[0]) { | |||
if(ok) | if(ok) | |||
ok = (SelectorGetTmp(I->G, selection, s1) >= 0); | ok = (SelectorGetTmp(I->G, selection, s1) >= 0); | |||
if(ok) | if(ok) | |||
skipping to change at line 1333 | skipping to change at line 1334 | |||
level); | level); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} else { | } else { | |||
result.status = PyMOLstatus_FAILURE; | result.status = PyMOLstatus_FAILURE; | |||
} | } | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdIsomesh(CPyMOL * I, char *name, char *map_name, floa | PyMOLreturn_status PyMOL_CmdIsomesh(CPyMOL * I, const char *name, const char *ma | |||
t level, | p_name, float level, | |||
char *selection, float buffer, int state, fl | const char *selection, float buffer, int sta | |||
oat carve, | te, float carve, | |||
int source_state, int quiet) | int source_state, int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
OrthoLineType s1 = ""; | OrthoLineType s1 = ""; | |||
PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | |||
int box_mode = 0; | int box_mode = 0; | |||
PYMOL_API_LOCK if(selection && selection[0]) { | PYMOL_API_LOCK if(selection && selection[0]) { | |||
if(ok) | if(ok) | |||
ok = (SelectorGetTmp(I->G, selection, s1) >= 0); | ok = (SelectorGetTmp(I->G, selection, s1) >= 0); | |||
if(ok) | if(ok) | |||
skipping to change at line 1359 | skipping to change at line 1360 | |||
state - 1, carve, source_state - 1, quiet, 0, box_m ode, | state - 1, carve, source_state - 1, quiet, 0, box_m ode, | |||
level); | level); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} else { | } else { | |||
result.status = PyMOLstatus_FAILURE; | result.status = PyMOLstatus_FAILURE; | |||
} | } | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdIsosurface(CPyMOL * I, char *name, char *map_name, | PyMOLreturn_status PyMOL_CmdIsosurface(CPyMOL * I, const char *name, const char | |||
float level, char *selection, float buffe | *map_name, | |||
r, | float level, const char *selection, float | |||
buffer, | ||||
int state, float carve, int source_state, int side, | int state, float carve, int source_state, int side, | |||
int mode, int quiet) | int mode, int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
OrthoLineType s1 = ""; | OrthoLineType s1 = ""; | |||
PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | |||
int box_mode = 0; | int box_mode = 0; | |||
PYMOL_API_LOCK if(selection && selection[0]) { | PYMOL_API_LOCK if(selection && selection[0]) { | |||
if(ok) | if(ok) | |||
ok = (SelectorGetTmp(I->G, selection, s1) >= 0); | ok = (SelectorGetTmp(I->G, selection, s1) >= 0); | |||
skipping to change at line 1387 | skipping to change at line 1388 | |||
state - 1, carve, source_state - 1, side, quiet, mode, | state - 1, carve, source_state - 1, side, quiet, mode, | |||
box_mode); | box_mode); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} else { | } else { | |||
result.status = PyMOLstatus_FAILURE; | result.status = PyMOLstatus_FAILURE; | |||
} | } | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdGradient(CPyMOL * I, char *name, char *map_name, | PyMOLreturn_status PyMOL_CmdGradient(CPyMOL * I, const char *name, const char *m | |||
float minimum, float maximum, char *selecti | ap_name, | |||
on, | float minimum, float maximum, const char *s | |||
election, | ||||
float buffer, int state, float carve, | float buffer, int state, float carve, | |||
int source_state, int quiet) | int source_state, int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
OrthoLineType s1 = ""; | OrthoLineType s1 = ""; | |||
PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | |||
int box_mode = 0; | int box_mode = 0; | |||
PYMOL_API_LOCK if(selection && selection[0]) { | PYMOL_API_LOCK if(selection && selection[0]) { | |||
if(ok) | if(ok) | |||
ok = (SelectorGetTmp(I->G, selection, s1) >= 0); | ok = (SelectorGetTmp(I->G, selection, s1) >= 0); | |||
skipping to change at line 1415 | skipping to change at line 1416 | |||
state - 1, carve, source_state - 1, quiet, 3, box_m ode, | state - 1, carve, source_state - 1, quiet, 3, box_m ode, | |||
maximum); | maximum); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} else { | } else { | |||
result.status = PyMOLstatus_FAILURE; | result.status = PyMOLstatus_FAILURE; | |||
} | } | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_float PyMOL_CmdIsolevel(CPyMOL * I, char *name, float level, int sta te, | PyMOLreturn_float PyMOL_CmdIsolevel(CPyMOL * I, const char *name, float level, i nt state, | |||
int query, int quiet) | int query, int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
OrthoLineType s1 = ""; | OrthoLineType s1 = ""; | |||
PyMOLreturn_float result; | PyMOLreturn_float result; | |||
PYMOL_API_LOCK if(ok) { | PYMOL_API_LOCK if(ok) { | |||
ok = ExecutiveIsolevel(I->G, name, level, state - 1, query, &result.value, q uiet); | ok = ExecutiveIsolevel(I->G, name, level, state - 1, query, &result.value, q uiet); | |||
result.status = get_status_ok(ok); | result.status = get_status_ok(ok); | |||
} else { | } else { | |||
result.status = PyMOLstatus_FAILURE; | result.status = PyMOLstatus_FAILURE; | |||
result.value = 0.0F; | result.value = 0.0F; | |||
} | } | |||
SelectorFreeTmp(I->G, s1); | SelectorFreeTmp(I->G, s1); | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
static int word_count(char *src) | static int word_count(const char *src) | |||
{ /* only works for ascii */ | { /* only works for ascii */ | |||
int cnt = 0; | int cnt = 0; | |||
while((*src) && ((*src) < 33)) /* skip leading whitespace */ | while((*src) && ((*src) < 33)) /* skip leading whitespace */ | |||
src++; | src++; | |||
while(*src) { | while(*src) { | |||
if((*src) > 32) { | if((*src) > 32) { | |||
cnt++; | cnt++; | |||
while((*src) && ((*src) > 32)) | while((*src) && ((*src) > 32)) | |||
src++; | src++; | |||
} | } | |||
while((*src) && ((*src) < 33)) | while((*src) && ((*src) < 33)) | |||
src++; | src++; | |||
} | } | |||
return cnt; | return cnt; | |||
} | } | |||
static char *next_word(char *src, char *dst, int buf_size) | static const char *next_word(const char *src, char *dst, int buf_size) | |||
{ /* only works for ascii */ | { /* only works for ascii */ | |||
while((*src) && ((*src) < 33)) /* skip leading whitespace */ | while((*src) && ((*src) < 33)) /* skip leading whitespace */ | |||
src++; | src++; | |||
while(*src) { | while(*src) { | |||
if((*src) > 32) { | if((*src) > 32) { | |||
while((*src) && ((*src) > 32) && (buf_size > 1)) { | while((*src) && ((*src) > 32) && (buf_size > 1)) { | |||
*(dst++) = *(src++); | *(dst++) = *(src++); | |||
buf_size--; | buf_size--; | |||
} | } | |||
break; | break; | |||
} | } | |||
} | } | |||
dst[0] = 0; | dst[0] = 0; | |||
return src; | return src; | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdRampNew(CPyMOL * I, char *name, char *map, float *ra | PyMOLreturn_status PyMOL_CmdRampNew(CPyMOL * I, const char *name, const char *ma | |||
nge, | p, float *range, | |||
int n_level, char *color, int state, char *s | int n_level, const char *color, int state, c | |||
election, | onst char *selection, | |||
float beyond, float within, float sigma, | float beyond, float within, float sigma, | |||
int zero, int calc_mode, int quiet) | int zero, int calc_mode, int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | |||
OrthoLineType s1 = ""; | OrthoLineType s1 = ""; | |||
float *color_vla = NULL; | float *color_vla = NULL; | |||
float *range_vla = NULL; | float *range_vla = NULL; | |||
PYMOL_API_LOCK if(selection && selection[0]) { | PYMOL_API_LOCK if(selection && selection[0]) { | |||
if(ok) | if(ok) | |||
skipping to change at line 1563 | skipping to change at line 1564 | |||
* content: Either file name or file contents, depending on "content_type" | * content: Either file name or file contents, depending on "content_type" | |||
* content_type: "filename", "string", "raw", or "cgo" | * content_type: "filename", "string", "raw", or "cgo" | |||
* content_length: Length of "content", if it's not a file name or a | * content_length: Length of "content", if it's not a file name or a | |||
* null-terminated string (pass -1). | * null-terminated string (pass -1). | |||
* content_format: The file format, e.g. "pdb", "sdf", "mol2", ... | * content_format: The file format, e.g. "pdb", "sdf", "mol2", ... | |||
* object_name: New object name. Can be empty if "content_type" is | * object_name: New object name. Can be empty if "content_type" is | |||
* "filename". | * "filename". | |||
*/ | */ | |||
static PyMOLreturn_status Loader(CPyMOL * I, const char *content, const char *co ntent_type, | static PyMOLreturn_status Loader(CPyMOL * I, const char *content, const char *co ntent_type, | |||
int content_length, const char *content_format, | int content_length, const char *content_format, | |||
char *object_name, int state, | const char *object_name, int state, | |||
int discrete, int finish, | int discrete, int finish, | |||
int quiet, int multiplex, int zoom) | int quiet, int multiplex, int zoom) | |||
{ | { | |||
PyMOLGlobals * G = I->G; | PyMOLGlobals * G = I->G; | |||
bool content_is_filename = false; | bool content_is_filename = false; | |||
int ok = true; | int ok = true; | |||
WordType obj_name; | WordType obj_name; | |||
// `content` can be a file name, or the file contents | // `content` can be a file name, or the file contents | |||
if (strcmp(content_type, "filename") == 0) { | if (strcmp(content_type, "filename") == 0) { | |||
skipping to change at line 1642 | skipping to change at line 1643 | |||
content_format, content_type ENDFB(G); | content_format, content_type ENDFB(G); | |||
ok = false; | ok = false; | |||
} | } | |||
if(ok) { | if(ok) { | |||
ok = ExecutiveLoad(I->G, | ok = ExecutiveLoad(I->G, | |||
content, content_length, | content, content_length, | |||
pymol_content_type, | pymol_content_type, | |||
object_name, | object_name, | |||
state - 1, zoom, discrete, finish, multiplex, quiet, NULL); | state - 1, zoom, discrete, finish, multiplex, quiet, NULL, 0, NULL); | |||
} | } | |||
} | } | |||
} | } | |||
if (ok) | if (ok) | |||
PyMOL_NeedRedisplay(I); | PyMOL_NeedRedisplay(I); | |||
return return_status_ok(ok); | return return_status_ok(ok); | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdLoad(CPyMOL * I, | PyMOLreturn_status PyMOL_CmdLoad(CPyMOL * I, | |||
const char *content, | const char *content, | |||
const char *content_type, | const char *content_type, | |||
const char *content_format, | const char *content_format, | |||
char *object_name, int state, | const char *object_name, int state, | |||
int discrete, int finish, | int discrete, int finish, | |||
int quiet, int multiplex, int zoom) | int quiet, int multiplex, int zoom) | |||
{ | { | |||
PyMOLreturn_status status = { PyMOLstatus_FAILURE }; | PyMOLreturn_status status = { PyMOLstatus_FAILURE }; | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
status = Loader(I, content, content_type, -1, content_format, object_name, | status = Loader(I, content, content_type, -1, content_format, object_name, | |||
state, discrete, finish, quiet, multiplex, zoom); | state, discrete, finish, quiet, multiplex, zoom); | |||
PYMOL_API_UNLOCK return status; | PYMOL_API_UNLOCK return status; | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdLoadRaw(CPyMOL * I, | PyMOLreturn_status PyMOL_CmdLoadRaw(CPyMOL * I, | |||
const char *content, | const char *content, | |||
int content_length, | int content_length, | |||
const char *content_format, | const char *content_format, | |||
char *object_name, int state, | const char *object_name, int state, | |||
int discrete, int finish, | int discrete, int finish, | |||
int quiet, int multiplex, int zoom) | int quiet, int multiplex, int zoom) | |||
{ | { | |||
PyMOLreturn_status status = { PyMOLstatus_FAILURE }; | PyMOLreturn_status status = { PyMOLstatus_FAILURE }; | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
status = Loader(I, content, "raw", content_length, content_format, | status = Loader(I, content, "raw", content_length, content_format, | |||
object_name, state, discrete, finish, quiet, multiplex, zoom ); | object_name, state, discrete, finish, quiet, multiplex, zoom ); | |||
PYMOL_API_UNLOCK return status; | PYMOL_API_UNLOCK return status; | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdLoadCGO(CPyMOL * I, | PyMOLreturn_status PyMOL_CmdLoadCGO(CPyMOL * I, | |||
const float *content, | const float *content, | |||
int content_length, | int content_length, | |||
char *object_name, int state, int quiet, int zoom) | const char *object_name, int state, int quie t, int zoom) | |||
{ | { | |||
PyMOLreturn_status status = { PyMOLstatus_FAILURE }; | PyMOLreturn_status status = { PyMOLstatus_FAILURE }; | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
status = Loader(I, (char *) content, "cgo", content_length, "cgo", | status = Loader(I, (char *) content, "cgo", content_length, "cgo", | |||
object_name, state, 0, 1, quiet, 0, zoom); | object_name, state, 0, 1, quiet, 0, zoom); | |||
PYMOL_API_UNLOCK return status; | PYMOL_API_UNLOCK return status; | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdCreate(CPyMOL * I, | PyMOLreturn_status PyMOL_CmdCreate(CPyMOL * I, | |||
const char *name, | const char *name, | |||
const char *selection, int source_state, | const char *selection, int source_state, | |||
int target_state, int discrete, | int target_state, int discrete, | |||
int zoom, int quiet, int singletons, | int zoom, int quiet, int singletons, | |||
const char *extract, int copy_properties) | const char *extract, int copy_properties) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
ok = ExecutiveSeleToObject(I->G, name, selection, source_state, target_state , | ok = ExecutiveSeleToObject(I->G, name, selection, source_state, target_state , | |||
discrete, zoom, quiet, singletons); | discrete, zoom, quiet, singletons, copy_propertie s); | |||
PYMOL_API_UNLOCK return return_status_ok(ok); | PYMOL_API_UNLOCK return return_status_ok(ok); | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdPseudoatom(CPyMOL * I, char *object_name, char *sele | PyMOLreturn_status PyMOL_CmdPseudoatom(CPyMOL * I, const char *object_name, cons | |||
ction, | t char *selection, | |||
char *name, char *resn, char *resi, char * | const char *name, const char *resn, const | |||
chain, | char *resi, const char *chain, | |||
char *segi, char *elem, float vdw, int het | const char *segi, const char *elem, float | |||
atm, | vdw, int hetatm, | |||
float b, float q, char *color, char *label | float b, float q, const char *color, const | |||
, | char *label, | |||
int use_xyz, float x, float y, float z, | int use_xyz, float x, float y, float z, | |||
int state, int mode, int quiet) | int state, int mode, int quiet) | |||
{ | { | |||
int ok = true; | int ok = true; | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
if(ok) { | if(ok) { | |||
OrthoLineType s1; | OrthoLineType s1; | |||
int color_index = ColorGetIndex(I->G, color); | int color_index = ColorGetIndex(I->G, color); | |||
ok = (SelectorGetTmp2(I->G, selection, s1)) >= 0; | ok = (SelectorGetTmp2(I->G, selection, s1)) >= 0; | |||
if(ok) { | if(ok) { | |||
skipping to change at line 1831 | skipping to change at line 1832 | |||
0, /* multisample */ | 0, /* multisample */ | |||
1, /* window_visible */ | 1, /* window_visible */ | |||
0, /* read_stdin */ | 0, /* read_stdin */ | |||
0, /* presentation */ | 0, /* presentation */ | |||
0, /* defer builds mode */ | 0, /* defer builds mode */ | |||
0, /* full screen mode */ | 0, /* full screen mode */ | |||
-1, /* sphere mode */ | -1, /* sphere mode */ | |||
0, /* stereo capable */ | 0, /* stereo capable */ | |||
0, /* stereo mode */ | 0, /* stereo mode */ | |||
-1, /* zoom mode */ | -1, /* zoom mode */ | |||
0, /* launch_status */ | ||||
0, /* no quit */ | 0, /* no quit */ | |||
}; | }; | |||
CPyMOLOptions *PyMOLOptions_New(void) | CPyMOLOptions *PyMOLOptions_New(void) | |||
{ | { | |||
CPyMOLOptions *result = NULL; | CPyMOLOptions *result = NULL; | |||
result = Calloc(CPyMOLOptions, 1); | result = Calloc(CPyMOLOptions, 1); | |||
if(result) | if(result) | |||
*result = Defaults; | *result = Defaults; | |||
return result; | return result; | |||
skipping to change at line 1989 | skipping to change at line 1991 | |||
} else { | } else { | |||
FreeP(result); | FreeP(result); | |||
} | } | |||
} | } | |||
return result; | return result; | |||
} | } | |||
static void _PyMOL_Config(CPyMOL * I) | static void _PyMOL_Config(CPyMOL * I) | |||
{ | { | |||
#ifndef _PYMOL_NO_MAIN | ||||
// also assign in PyMOL_DrawWithoutLock | ||||
I->G->HaveGUI = I->G->Option->pmgui; | I->G->HaveGUI = I->G->Option->pmgui; | |||
#endif | ||||
I->G->Security = I->G->Option->security; | I->G->Security = I->G->Option->security; | |||
} | } | |||
CPyMOL *PyMOL_New(void) | CPyMOL *PyMOL_New(void) | |||
{ | { | |||
CPyMOL *result = _PyMOL_New(); | CPyMOL *result = _PyMOL_New(); | |||
if(result && result->G) { | if(result && result->G) { | |||
result->G->Option = Calloc(CPyMOLOptions, 1); | result->G->Option = Calloc(CPyMOLOptions, 1); | |||
if(result->G->Option) | if(result->G->Option) | |||
(*result->G->Option) = Defaults; | (*result->G->Option) = Defaults; | |||
_PyMOL_Config(result); | _PyMOL_Config(result); | |||
} | } | |||
return result; | return result; | |||
} | } | |||
CPyMOL *PyMOL_NewWithOptions(CPyMOLOptions * option) | CPyMOL *PyMOL_NewWithOptions(const CPyMOLOptions * option) | |||
{ | { | |||
CPyMOL *result = _PyMOL_New(); | CPyMOL *result = _PyMOL_New(); | |||
if(result && result->G) { | if(result && result->G) { | |||
result->G->Option = Calloc(CPyMOLOptions, 1); | result->G->Option = Calloc(CPyMOLOptions, 1); | |||
if(result->G->Option) | if(result->G->Option) | |||
*(result->G->Option) = *option; | *(result->G->Option) = *option; | |||
_PyMOL_Config(result); | _PyMOL_Config(result); | |||
} | } | |||
result->G->StereoCapable = option->stereo_capable; | result->G->StereoCapable = option->stereo_capable; | |||
return result; | return result; | |||
} | } | |||
void PyMOL_Start(CPyMOL * I) | void PyMOL_Start(CPyMOL * I) | |||
{ | { | |||
PyMOLGlobals *G = I->G; | PyMOLGlobals *G = I->G; | |||
// It's possible to change this from Python, functions which rely on | ||||
// C locale should reset it before doing printf, atof, etc. | ||||
std::setlocale(LC_NUMERIC, "C"); | ||||
G->Context = OVContext_New(); | G->Context = OVContext_New(); | |||
G->Lexicon = OVLexicon_New(G->Context->heap); | G->Lexicon = OVLexicon_New(G->Context->heap); | |||
if(OVreturn_IS_ERROR(PyMOL_InitAPI(I))) { | if(OVreturn_IS_ERROR(PyMOL_InitAPI(I))) { | |||
printf("ERROR: PyMOL internal C API initialization failed.\n"); | printf("ERROR: PyMOL internal C API initialization failed.\n"); | |||
} | } | |||
// global lexicon "constants" | // global lexicon "constants" | |||
#define LEX_CONSTANTS_IMPL | #define LEX_CONSTANTS_IMPL | |||
#include "lex_constants.h" | #include "lex_constants.h" | |||
MemoryCacheInit(G); | MemoryCacheInit(G); | |||
FeedbackInit(G, G->Option->quiet); | FeedbackInit(G, G->Option->quiet); | |||
WordInit(G); | WordInit(G); | |||
UtilInit(G); | UtilInit(G); | |||
ColorInit(G); | ColorInit(G); | |||
CGORendererInit(G); | CGORendererInit(G); | |||
ShaderMgrInit(G); | ||||
SettingInitGlobal(G, true, true, false); | SettingInitGlobal(G, true, true, false); | |||
SettingSetGlobal_i(G, cSetting_internal_gui, G->Option->internal_gui); | SettingSetGlobal_i(G, cSetting_internal_gui, G->Option->internal_gui); | |||
SettingSetGlobal_i(G, cSetting_internal_feedback, G->Option->internal_feedback ); | SettingSetGlobal_i(G, cSetting_internal_feedback, G->Option->internal_feedback ); | |||
TextureInit(G); | TextureInit(G); | |||
TypeInit(G); | TypeInit(G); | |||
TextInit(G); | TextInit(G); | |||
CharacterInit(G); | CharacterInit(G); | |||
PlugIOManagerInit(G); | PlugIOManagerInit(G); | |||
SphereInit(G); | SphereInit(G); | |||
OrthoInit(G, G->Option->show_splash); | OrthoInit(G, G->Option->show_splash); | |||
skipping to change at line 2065 | skipping to change at line 2075 | |||
SeekerInit(G); | SeekerInit(G); | |||
ButModeInit(G); | ButModeInit(G); | |||
ControlInit(G); | ControlInit(G); | |||
AtomInfoInit(G); | AtomInfoInit(G); | |||
SculptCacheInit(G); | SculptCacheInit(G); | |||
VFontInit(G); | VFontInit(G); | |||
ExecutiveInit(G); | ExecutiveInit(G); | |||
IsosurfInit(G); | IsosurfInit(G); | |||
TetsurfInit(G); | TetsurfInit(G); | |||
EditorInit(G); | EditorInit(G); | |||
ShaderMgrInit(G); | ||||
#ifdef TRACKER_UNIT_TEST | #ifdef TRACKER_UNIT_TEST | |||
TrackerUnitTest(G); | TrackerUnitTest(G); | |||
#endif | #endif | |||
/* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | /* BEGIN PROPRIETARY CODE SEGMENT (see disclaimer in "os_proprietary.h") */ | |||
#ifdef _MACPYMOL_XCODE | #ifdef _MACPYMOL_XCODE | |||
SettingSetGlobal_b(G, cSetting_stereo_double_pump_mono, true); | SettingSetGlobal_b(G, cSetting_stereo_double_pump_mono, true); | |||
if(G->Option->stereo_capable) { | if(G->Option->stereo_capable) { | |||
SettingSetGlobal_i(G, cSetting_stereo_mode, 1); | SettingSetGlobal_i(G, cSetting_stereo_mode, cStereo_quadbuffer); | |||
} | } | |||
/* SettingSetGlobal_i(G,cSetting_show_progress, 0); */ | /* SettingSetGlobal_i(G,cSetting_show_progress, 0); */ | |||
#endif | #endif | |||
/* END PROPRIETARY CODE SEGMENT */ | /* END PROPRIETARY CODE SEGMENT */ | |||
I->DrawnFlag = false; | I->DrawnFlag = false; | |||
I->RedisplayFlag = true; | I->RedisplayFlag = true; | |||
G->Ready = true; | G->Ready = true; | |||
} | } | |||
skipping to change at line 2106 | skipping to change at line 2115 | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
PyMOL_ConfigureShadersGL_WithoutLock(I); | PyMOL_ConfigureShadersGL_WithoutLock(I); | |||
PYMOL_API_UNLOCK | PYMOL_API_UNLOCK | |||
} | } | |||
#ifndef _PYMOL_NOPY | #ifndef _PYMOL_NOPY | |||
void PyMOL_StartWithPython(CPyMOL * I) | void PyMOL_StartWithPython(CPyMOL * I) | |||
{ | { | |||
PyMOL_Start(I); | PyMOL_Start(I); | |||
PyMOL_ConfigureShadersGL_WithoutLock(I); | ||||
/* now locate all the C to Python function hooks and objects we need */ | /* now locate all the C to Python function hooks and objects we need */ | |||
#ifdef _MACPYMOL_XCODE | #ifdef _MACPYMOL_XCODE | |||
PInit(I->G, true); | PInit(I->G, true); | |||
#else | #else | |||
PInit(I->G, false); | PInit(I->G, false); | |||
#endif | #endif | |||
/* and begin the initialization sequence */ | /* and begin the initialization sequence */ | |||
skipping to change at line 2160 | skipping to change at line 2168 | |||
MovieScenesFree(G); | MovieScenesFree(G); | |||
OrthoFree(G); | OrthoFree(G); | |||
CShaderMgrFree(G); | CShaderMgrFree(G); | |||
SettingFreeGlobal(G); | SettingFreeGlobal(G); | |||
CharacterFree(G); | CharacterFree(G); | |||
TextFree(G); | TextFree(G); | |||
TypeFree(G); | TypeFree(G); | |||
TextureFree(G); | TextureFree(G); | |||
SphereFree(G); | SphereFree(G); | |||
PlugIOManagerFree(G); | PlugIOManagerFree(G); | |||
PFree(); | PFree(G); | |||
CGORendererFree(G); | CGORendererFree(G); | |||
ColorFree(G); | ColorFree(G); | |||
UtilFree(G); | UtilFree(G); | |||
WordFree(G); | WordFree(G); | |||
FeedbackFree(G); | FeedbackFree(G); | |||
MemoryCacheDone(G); | MemoryCacheDone(G); | |||
PyMOL_PurgeAPI(I); | PyMOL_PurgeAPI(I); | |||
/* printf("%d \n", OVLexicon_GetNActive(G->Lexicon)); */ | /* printf("%d \n", OVLexicon_GetNActive(G->Lexicon)); */ | |||
OVLexicon_Del(G->Lexicon); | OVLexicon_Del(G->Lexicon); | |||
OVContext_Del(G->Context); | OVContext_Del(G->Context); | |||
#ifndef _PYMOL_NOPY | ||||
FreeP(G->P_inst); | ||||
#endif | ||||
} | } | |||
void PyMOL_Free(CPyMOL * I) | void PyMOL_Free(CPyMOL * I) | |||
{ | { | |||
#ifndef _PYMOL_ACTIVEX | #if !defined(_PYMOL_ACTIVEX) && !defined(_MACPYMOL_XCODE) | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
#endif | #endif | |||
/* take PyMOL down gracefully */ | /* take PyMOL down gracefully */ | |||
PyMOLOptions_Free(I->G->Option); | PyMOLOptions_Free(I->G->Option); | |||
#ifndef _PYMOL_NOPY | #ifndef _PYMOL_NOPY | |||
FreeP(I->G->P_inst); | ||||
if(I->G == SingletonPyMOLGlobals) | if(I->G == SingletonPyMOLGlobals) | |||
SingletonPyMOLGlobals = NULL; | SingletonPyMOLGlobals = NULL; | |||
#endif | #endif | |||
FreeP(I->G); | FreeP(I->G); | |||
FreeP(I); | FreeP(I); | |||
return; | return; | |||
#ifndef _PYMOL_ACTIVEX | #if !defined(_PYMOL_ACTIVEX) && !defined(_MACPYMOL_XCODE) | |||
PYMOL_API_UNLOCK; | PYMOL_API_UNLOCK; | |||
#endif | #endif | |||
} | } | |||
struct _PyMOLGlobals *PyMOL_GetGlobals(CPyMOL * I) | struct _PyMOLGlobals *PyMOL_GetGlobals(CPyMOL * I) | |||
{ | { | |||
return I->G; | return I->G; | |||
} | } | |||
struct _PyMOLGlobals **PyMOL_GetGlobalsHandle(CPyMOL * I) | struct _PyMOLGlobals **PyMOL_GetGlobalsHandle(CPyMOL * I) | |||
skipping to change at line 2283 | skipping to change at line 2288 | |||
#endif | #endif | |||
} | } | |||
void PyMOL_DrawWithoutLock(CPyMOL * I); | void PyMOL_DrawWithoutLock(CPyMOL * I); | |||
void PyMOL_Draw(CPyMOL * I){ | void PyMOL_Draw(CPyMOL * I){ | |||
PYMOL_API_LOCK_MODAL | PYMOL_API_LOCK_MODAL | |||
PyMOL_DrawWithoutLock(I); | PyMOL_DrawWithoutLock(I); | |||
PYMOL_API_UNLOCK | PYMOL_API_UNLOCK | |||
} | } | |||
static void PyMOL_LaunchStatus_Feedback(PyMOLGlobals * G) | ||||
{ | ||||
G->LaunchStatus |= G->Option->launch_status; | ||||
if(G->StereoCapable) { | ||||
OrthoAddOutput(G, | ||||
" OpenGL quad-buffer stereo 3D detected and enabled.\n");; | ||||
} else { | ||||
if(G->LaunchStatus & cPyMOLGlobals_LaunchStatus_StereoFailed) { | ||||
FeedbackAddColored(G, | ||||
"Error: The requested stereo 3D visualization mode is not available.\n | ||||
", | ||||
FB_Errors); | ||||
} | ||||
} | ||||
if(G->LaunchStatus & cPyMOLGlobals_LaunchStatus_MultisampleFailed) { | ||||
FeedbackAddColored(G, | ||||
"Error: The requested multisampling mode is not available.\n", | ||||
FB_Errors); | ||||
} | ||||
} | ||||
#ifndef PURE_OPENGL_ES_2 | ||||
static void check_gl_stereo_capable(PyMOLGlobals * G) | ||||
{ | ||||
GLboolean state; | ||||
glGetBooleanv(GL_STEREO, &state); | ||||
G->StereoCapable = state; | ||||
if (state && G->Option->stereo_mode == cStereo_default) { | ||||
SettingSetGlobal_i(G, cSetting_stereo_mode, cStereo_quadbuffer); | ||||
} else if (!state && G->Option->stereo_mode == cStereo_quadbuffer) { | ||||
G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_StereoFailed; | ||||
} | ||||
if (G->Option->multisample) { | ||||
GLint samplebuffers = 0; | ||||
glGetIntegerv(GL_SAMPLE_BUFFERS, &samplebuffers); | ||||
if (!samplebuffers) { | ||||
G->LaunchStatus |= cPyMOLGlobals_LaunchStatus_MultisampleFailed; | ||||
} | ||||
} | ||||
} | ||||
#endif | ||||
void PyMOL_DrawWithoutLock(CPyMOL * I) | void PyMOL_DrawWithoutLock(CPyMOL * I) | |||
{ | { | |||
if (!I->done_ConfigureShaders) { | ||||
I->done_ConfigureShaders = true; | ||||
I->G->HaveGUI = I->G->Option->pmgui; | ||||
#ifndef PURE_OPENGL_ES_2 | ||||
// stereo test with PyQt5 on Linux is broken (QTBUG-59636), so we | ||||
// test for stereo here | ||||
if (I->G->HaveGUI && !I->G->StereoCapable) { | ||||
check_gl_stereo_capable(I->G); | ||||
} | ||||
#endif | ||||
PyMOL_LaunchStatus_Feedback(I->G); | ||||
PyMOL_ConfigureShadersGL_WithoutLock(I); | ||||
} | ||||
PyMOLGlobals * G = I->G; | PyMOLGlobals * G = I->G; | |||
if(I->ModalDraw) { | if(I->ModalDraw) { | |||
if(G->HaveGUI) { | if(G->HaveGUI) { | |||
PyMOL_PushValidContext(I); | PyMOL_PushValidContext(I); | |||
setup_gl_state(); | setup_gl_state(); | |||
} | } | |||
{ | { | |||
PyMOLModalDrawFn *fn = I->ModalDraw; | PyMOLModalDrawFn *fn = I->ModalDraw; | |||
I->ModalDraw = NULL; /* always resets to NULL! */ | I->ModalDraw = NULL; /* always resets to NULL! */ | |||
fn(G); | fn(G); | |||
skipping to change at line 2483 | skipping to change at line 2551 | |||
PXDecRef(PYOBJECT_CALLMETHOD(G->P_inst->obj, "launch_gui", "O", G->P_inst- >obj)); | PXDecRef(PYOBJECT_CALLMETHOD(G->P_inst->obj, "launch_gui", "O", G->P_inst- >obj)); | |||
#endif | #endif | |||
/* END PROPRIETARY CODE SEGMENT */ | /* END PROPRIETARY CODE SEGMENT */ | |||
PXDecRef(PYOBJECT_CALLMETHOD | PXDecRef(PYOBJECT_CALLMETHOD | |||
(G->P_inst->obj, "adapt_to_hardware", "O", G->P_inst->obj)); | (G->P_inst->obj, "adapt_to_hardware", "O", G->P_inst->obj)); | |||
if(PyErr_Occurred()) | if(PyErr_Occurred()) | |||
PyErr_Print(); | PyErr_Print(); | |||
if(G->StereoCapable) { | ||||
OrthoAddOutput(G, | ||||
" OpenGL quad-buffer stereo 3D detected and enabled.\n"); | ||||
; | ||||
} else { | ||||
if(G->LaunchStatus & cPyMOLGlobals_LaunchStatus_StereoFailed) { | ||||
OrthoAddOutput(G, | ||||
"Error: The requested stereo 3D visualization mode is n | ||||
ot available."); | ||||
} | ||||
} | ||||
if(G->LaunchStatus & cPyMOLGlobals_LaunchStatus_MultisampleFailed) { | ||||
OrthoAddOutput(G, | ||||
"Error: The requested multisampling mode is not available | ||||
."); | ||||
} | ||||
PXDecRef(PYOBJECT_CALLMETHOD(G->P_inst->obj, "exec_deferred", "O", G->P_in st->obj)); | PXDecRef(PYOBJECT_CALLMETHOD(G->P_inst->obj, "exec_deferred", "O", G->P_in st->obj)); | |||
if(PyErr_Occurred()) | if(PyErr_Occurred()) | |||
PyErr_Print(); | PyErr_Print(); | |||
PUnblock(G); | PUnblock(G); | |||
PFlush(G); | PFlush(G); | |||
} | } | |||
} | } | |||
#endif | #endif | |||
skipping to change at line 2560 | skipping to change at line 2613 | |||
void PyMOL_NeedSwap(CPyMOL * I) | void PyMOL_NeedSwap(CPyMOL * I) | |||
{ | { | |||
I->SwapFlag = true; | I->SwapFlag = true; | |||
} | } | |||
void PyMOL_NeedReshape(CPyMOL * I, int mode, int x, int y, int width, int height ) | void PyMOL_NeedReshape(CPyMOL * I, int mode, int x, int y, int width, int height ) | |||
{ | { | |||
PyMOLGlobals *G = I->G; | PyMOLGlobals *G = I->G; | |||
if(width < 0) { | if(width < 0) { | |||
if (!G->HaveGUI) | ||||
return; | ||||
int h; | int h; | |||
BlockGetSize(SceneGetBlock(G), &width, &h); | BlockGetSize(SceneGetBlock(G), &width, &h); | |||
if(SettingGetGlobal_b(G, cSetting_internal_gui)) | if(SettingGetGlobal_b(G, cSetting_internal_gui)) | |||
width += SettingGetGlobal_i(G, cSetting_internal_gui_width); | width += DIP2PIXEL(SettingGetGlobal_i( G, cSetting_internal_gui_width)); | |||
} | } | |||
/* if height is negative, force a reshape based on the current height */ | /* if height is negative, force a reshape based on the current height */ | |||
if(height < 0) { | if(height < 0) { | |||
int w; | int w; | |||
int internal_feedback; | int internal_feedback; | |||
BlockGetSize(SceneGetBlock(G), &w, &height); | BlockGetSize(SceneGetBlock(G), &w, &height); | |||
internal_feedback = SettingGetGlobal_i(G, cSetting_internal_feedback); | internal_feedback = SettingGetGlobal_i(G, cSetting_internal_feedback); | |||
if(internal_feedback) | if(internal_feedback) | |||
height += (internal_feedback - 1) * cOrthoLineHeight + cOrthoBottomSceneMa rgin; | height += (internal_feedback - 1) * cOrthoLineHeight + cOrthoBottomSceneMa rgin; | |||
if(SettingGetGlobal_b(G, cSetting_seq_view) | if(SettingGetGlobal_b(G, cSetting_seq_view) | |||
&& !SettingGetGlobal_b(G, cSetting_seq_view_overlay)) { | && !SettingGetGlobal_b(G, cSetting_seq_view_overlay)) { | |||
height += SeqGetHeight(G); | height += SeqGetHeight(G); | |||
} | } | |||
height += MovieGetPanelHeight(G); | height += MovieGetPanelHeight(G); | |||
} | } | |||
if(G->HaveGUI) { | if(G->HaveGUI) { | |||
float sf = DIP2PIXEL(1); | ||||
I->Reshape[1] = x / sf; | ||||
I->Reshape[2] = y / sf; | ||||
I->Reshape[3] = width / sf; | ||||
I->Reshape[4] = height / sf; | ||||
I->ReshapeFlag = true; | I->ReshapeFlag = true; | |||
I->Reshape[0] = mode; | I->Reshape[0] = mode; | |||
I->Reshape[1] = x; | ||||
I->Reshape[2] = y; | ||||
I->Reshape[3] = width; | ||||
I->Reshape[4] = height; | ||||
PyMOL_NeedRedisplay(I); | PyMOL_NeedRedisplay(I); | |||
} else { | } else { | |||
/* if no gui, then force immediate reshape */ | /* if no gui, then force immediate reshape */ | |||
PyMOLGlobals *G = I->G; | PyMOLGlobals *G = I->G; | |||
G->Option->winX = width; | G->Option->winX = width; | |||
G->Option->winY = height; | G->Option->winY = height; | |||
OrthoReshape(G, width, height, true); | OrthoReshape(G, width, height, true); | |||
} | } | |||
skipping to change at line 2907 | skipping to change at line 2966 | |||
I->G->Interrupt = value; | I->G->Interrupt = value; | |||
} | } | |||
} | } | |||
void PyMOL_Drag(CPyMOL * I, int x, int y, int modifiers) | void PyMOL_Drag(CPyMOL * I, int x, int y, int modifiers) | |||
{ | { | |||
PYMOL_API_LOCK OrthoDrag(I->G, x, y, modifiers); | PYMOL_API_LOCK OrthoDrag(I->G, x, y, modifiers); | |||
I->DraggedFlag = true; | I->DraggedFlag = true; | |||
PYMOL_API_UNLOCK} | PYMOL_API_UNLOCK} | |||
/* | ||||
* Mouse button and keyboard press handler | ||||
* | ||||
* button: mouse button or key code | ||||
* state: | ||||
* -2 = key press with GLUT_KEY_* special code | ||||
* -1 = key press with ascii code | ||||
* 0 = mouse down | ||||
* 1 = mouse up | ||||
* x, y: mouse pointer position | ||||
* modifiers: SHIFT/CTRL/ALT bitmask | ||||
*/ | ||||
void PyMOL_Button(CPyMOL * I, int button, int state, int x, int y, int modifiers ) | void PyMOL_Button(CPyMOL * I, int button, int state, int x, int y, int modifiers ) | |||
{ | { | |||
PYMOL_API_LOCK OrthoButton(I->G, button, state, x, y, modifiers); | PYMOL_API_LOCK | |||
if (state == -1) { | ||||
PyMOL_Key(I, (unsigned char)button, x, y, modifiers); | ||||
} else if (state == -2) { | ||||
PyMOL_Special(I, button, x, y, modifiers); | ||||
} else { | ||||
OrthoButton(I->G, button, state, x, y, modifiers); | ||||
} | ||||
PYMOL_API_UNLOCK} | PYMOL_API_UNLOCK} | |||
void PyMOL_SetSwapBuffersFn(CPyMOL * I, PyMOLSwapBuffersFn * fn) | void PyMOL_SetSwapBuffersFn(CPyMOL * I, PyMOLSwapBuffersFn * fn) | |||
{ | { | |||
I->SwapFn = fn; | I->SwapFn = fn; | |||
} | } | |||
void PyMOL_SwapBuffers(CPyMOL * I) | void PyMOL_SwapBuffers(CPyMOL * I) | |||
{ | { | |||
if(I->SwapFn && I->G->ValidContext) { | if(I->SwapFn && I->G->ValidContext) { | |||
skipping to change at line 2950 | skipping to change at line 3028 | |||
if(I && I->G && (I->G->ValidContext > 0)) | if(I && I->G && (I->G->ValidContext > 0)) | |||
I->G->ValidContext--; | I->G->ValidContext--; | |||
} | } | |||
void PyMOL_SetStereoCapable(CPyMOL * I, int stereoCapable){ | void PyMOL_SetStereoCapable(CPyMOL * I, int stereoCapable){ | |||
PYMOL_API_LOCK PyMOLGlobals * G = I->G; | PYMOL_API_LOCK PyMOLGlobals * G = I->G; | |||
G->StereoCapable = stereoCapable; | G->StereoCapable = stereoCapable; | |||
if (SettingGetGlobal_b(I->G, cSetting_stereo_mode)==0){ | if (SettingGetGlobal_b(I->G, cSetting_stereo_mode)==0){ | |||
/* if users haven't set stereo_mode, then set it to default */ | /* if users haven't set stereo_mode, then set it to default */ | |||
if (G->StereoCapable){ | if (G->StereoCapable){ | |||
SettingSetGlobal_i(I->G, cSetting_stereo_mode, 1); /* quadbuffer if w e can */ | SettingSetGlobal_i(I->G, cSetting_stereo_mode, cStereo_quadbuffer); / * quadbuffer if we can */ | |||
} else { | } else { | |||
SettingSetGlobal_i(I->G, cSetting_stereo_mode, 2); /* otherwise cross eye by default */ | SettingSetGlobal_i(I->G, cSetting_stereo_mode, cStereo_crosseye); /* otherwise crosseye by default */ | |||
} | } | |||
} else if (G->StereoCapable && SettingGetGlobal_b(G, cSetting_stereo)){ | } else if (G->StereoCapable && SettingGetGlobal_b(G, cSetting_stereo)){ | |||
SettingSetGlobal_i(I->G, cSetting_stereo_mode, SettingGetGlobal_b(I->G, cSet ting_stereo_mode)); | SettingSetGlobal_i(I->G, cSetting_stereo_mode, SettingGetGlobal_b(I->G, cSet ting_stereo_mode)); | |||
} | } | |||
SceneUpdateStereo(I->G); | SceneUpdateStereo(I->G); | |||
PYMOL_API_UNLOCK | PYMOL_API_UNLOCK | |||
} | } | |||
void PyMOL_InitializeCMol(CPyMOL * I){ | void PyMOL_InitializeCMol(CPyMOL * I){ | |||
PYMOL_API_LOCK PyMOLGlobals * G = I->G; | PYMOL_API_LOCK PyMOLGlobals * G = I->G; | |||
skipping to change at line 3025 | skipping to change at line 3103 | |||
G->Feedback->Mask[FB_Scene] &= ~(FB_Results); /* suppress click messages */ | G->Feedback->Mask[FB_Scene] &= ~(FB_Results); /* suppress click messages */ | |||
PYMOL_API_UNLOCK} | PYMOL_API_UNLOCK} | |||
PyMOLreturn_status PyMOL_CmdRock(CPyMOL * I, int mode){ | PyMOLreturn_status PyMOL_CmdRock(CPyMOL * I, int mode){ | |||
PyMOLreturn_status result = { PyMOLstatus_SUCCESS }; | PyMOLreturn_status result = { PyMOLstatus_SUCCESS }; | |||
PYMOL_API_LOCK PyMOLGlobals * G = I->G; | PYMOL_API_LOCK PyMOLGlobals * G = I->G; | |||
ControlRock(G, mode); | ControlRock(G, mode); | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
PyMOLreturn_string_array PyMOL_CmdGetNames(CPyMOL * I, int mode, char *s0, int e nabled_only){ | PyMOLreturn_string_array PyMOL_CmdGetNames(CPyMOL * I, int mode, const char *s0, int enabled_only){ | |||
char *res; | char *res; | |||
char *p; | char *p; | |||
int c = 0; | int c = 0; | |||
int numstrs = 0; | int numstrs = 0; | |||
long reslen, pl = 0; | long reslen, pl = 0; | |||
OrthoLineType str0 = ""; | OrthoLineType str0 = ""; | |||
PyMOLreturn_string_array result = { PyMOLstatus_SUCCESS }; | PyMOLreturn_string_array result = { PyMOLstatus_SUCCESS }; | |||
PYMOL_API_LOCK PyMOLGlobals * G = I->G; | PYMOL_API_LOCK PyMOLGlobals * G = I->G; | |||
if (s0[0]){ | if (s0[0]){ | |||
skipping to change at line 3070 | skipping to change at line 3148 | |||
} | } | |||
} else { | } else { | |||
ok_except1: | ok_except1: | |||
result.array = NULL; | result.array = NULL; | |||
result.size = 0; | result.size = 0; | |||
} | } | |||
PYMOL_API_UNLOCK | PYMOL_API_UNLOCK | |||
return (result); | return (result); | |||
} | } | |||
PyMOLreturn_status PyMOL_CmdMapNew(CPyMOL * I, char *name, int type, float grid_ | PyMOLreturn_status PyMOL_CmdMapNew(CPyMOL * I, const char *name, int type, float | |||
spacing, | grid_spacing, | |||
char *selection, int state, int normalize, | const char *selection, int state, int normaliz | |||
e, | ||||
int zoom, int quiet){ | int zoom, int quiet){ | |||
int ok = true; | int ok = true; | |||
PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | |||
float grid[3]; | float grid[3]; | |||
float minCorner[3], maxCorner[3]; | float minCorner[3], maxCorner[3]; | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
grid[0] = grid[1] = grid[2] = grid_spacing ; | grid[0] = grid[1] = grid[2] = grid_spacing ; | |||
minCorner[0] = minCorner[1] = minCorner[2] = 0.; | minCorner[0] = minCorner[1] = minCorner[2] = 0.; | |||
maxCorner[0] = maxCorner[1] = maxCorner[2] = 1.; | maxCorner[0] = maxCorner[1] = maxCorner[2] = 1.; | |||
skipping to change at line 3134 | skipping to change at line 3212 | |||
result.array = retarr; | result.array = retarr; | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
static OVreturn_word get_button_code(CPyMOL * I, char *code); | static OVreturn_word get_button_code(CPyMOL * I, char *code); | |||
static OVreturn_word get_button_mod_code(CPyMOL * I, char *modcode); | static OVreturn_word get_button_mod_code(CPyMOL * I, char *modcode); | |||
static OVreturn_word get_button_action_code(CPyMOL * I, char *actioncode); | static OVreturn_word get_button_action_code(CPyMOL * I, char *actioncode); | |||
static OVreturn_word get_mouse_mode(CPyMOL * I, char *mousemode); | static OVreturn_word get_mouse_mode(CPyMOL * I, char *mousemode); | |||
PyMOLreturn_status PyMOL_SetButton(CPyMOL * I, char *button, char *modifier, cha r *action){ | PyMOLreturn_status PyMOL_SetButton(CPyMOL * I, const char *buttonarg, const char *modifierarg, const char *actionarg){ | |||
int ok = true; | int ok = true; | |||
OVreturn_word button_num, but_mod_num, act_code; | OVreturn_word button_num, but_mod_num, act_code; | |||
int but_code; | int but_code; | |||
PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | |||
OrthoLineType button, modifier, action; | ||||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
UtilNCopyToLower(button, button, strlen(button)+1); | UtilNCopyToLower(button, buttonarg, strlen(buttonarg)+1); | |||
UtilNCopyToLower(modifier, modifier, strlen(modifier)+1); | UtilNCopyToLower(modifier, modifierarg, strlen(modifierarg)+1); | |||
UtilNCopyToLower(action, action, strlen(action)+1); | UtilNCopyToLower(action, actionarg, strlen(actionarg)+1); | |||
ok = OVreturn_IS_OK(button_num = get_button_code(I, button)); | ok = OVreturn_IS_OK(button_num = get_button_code(I, button)); | |||
if (ok) ok = OVreturn_IS_OK((but_mod_num = get_button_mod_code(I, modifier))); | if (ok) ok = OVreturn_IS_OK((but_mod_num = get_button_mod_code(I, modifier))); | |||
if (ok) ok = OVreturn_IS_OK((act_code = get_button_action_code(I, action))); | if (ok) ok = OVreturn_IS_OK((act_code = get_button_action_code(I, action))); | |||
if (ok){ | if (ok){ | |||
/* This is directly from the button() function in controlling.py */ | /* This is directly from the button() function in controlling.py */ | |||
if (button_num.word < 3){ // normal button (L,M,R) | if (button_num.word < 3){ // normal button (L,M,R) | |||
if (but_mod_num.word < 4){ | if (but_mod_num.word < 4){ | |||
// none, shft, ctrl, ctsh | // none, shft, ctrl, ctsh | |||
but_code = button_num.word + 3*but_mod_num.word; | but_code = button_num.word + 3*but_mod_num.word; | |||
skipping to change at line 3176 | skipping to change at line 3254 | |||
// single and double clicks | // single and double clicks | |||
but_code = (16 + button_num.word -4) + but_mod_num.word * 6; | but_code = (16 + button_num.word -4) + but_mod_num.word * 6; | |||
} | } | |||
ButModeSet(I->G, but_code, act_code.word); | ButModeSet(I->G, but_code, act_code.word); | |||
result.status = PyMOLstatus_SUCCESS; | result.status = PyMOLstatus_SUCCESS; | |||
} | } | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
#include "buttonmodes.h" | #include "buttonmodes.h" | |||
PyMOLreturn_status PyMOL_SetMouseButtonMode(CPyMOL * I, char *modename){ | PyMOLreturn_status PyMOL_SetMouseButtonMode(CPyMOL * I, const char *modename){ | |||
int ok = true, i, start; | int ok = true, i, start; | |||
OVreturn_word mode; | OVreturn_word mode; | |||
PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | PyMOLreturn_status result = { PyMOLstatus_FAILURE }; | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
{ | { | |||
char *nmodename = (char*)malloc(strlen(modename)+1); | char *nmodename = (char*)malloc(strlen(modename)+1); | |||
UtilNCopyToLower((char*)nmodename, modename, strlen(modename)+1); | UtilNCopyToLower((char*)nmodename, modename, strlen(modename)+1); | |||
ok = OVreturn_IS_OK(mode = get_mouse_mode(I, (char*)nmodename)); | ok = OVreturn_IS_OK(mode = get_mouse_mode(I, (char*)nmodename)); | |||
free(nmodename); | free(nmodename); | |||
skipping to change at line 3262 | skipping to change at line 3340 | |||
#include "palettes.h" | #include "palettes.h" | |||
static OVreturn_word get_palette(CPyMOL * I, char *palette) | static OVreturn_word get_palette(CPyMOL * I, char *palette) | |||
{ | { | |||
OVreturn_word result; | OVreturn_word result; | |||
if(!OVreturn_IS_OK((result = OVLexicon_BorrowFromCString(I->Lex, palette)))) | if(!OVreturn_IS_OK((result = OVLexicon_BorrowFromCString(I->Lex, palette)))) | |||
return result; | return result; | |||
return OVOneToOne_GetForward(I->PaletteLexicon, result.word); | return OVOneToOne_GetForward(I->PaletteLexicon, result.word); | |||
} | } | |||
PyMOLreturn_float_array PyMOL_Spectrum(CPyMOL * I, char *expression, char *pal, char *selection, float minimum, float maximum, int byres, int quiet){ | PyMOLreturn_float_array PyMOL_Spectrum(CPyMOL * I, const char *expression, const char *pal, const char *selection, float minimum, float maximum, int byres, int quiet){ | |||
PyMOLreturn_float_array result = { PyMOLstatus_FAILURE }; | PyMOLreturn_float_array result = { PyMOLstatus_FAILURE }; | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
int ok = true; | int ok = true; | |||
int digits, first, last, array_pl, ret; | int digits, first, last, array_pl, ret; | |||
float min_ret, max_ret; | float min_ret, max_ret; | |||
char prefix[2]; | char prefix[2]; | |||
OVreturn_word pal_word; | OVreturn_word pal_word; | |||
char *palette = (char*)malloc(strlen(pal)+1); | char *palette = (char*)malloc(strlen(pal)+1); | |||
UtilNCopyToLower((char*)palette, pal, strlen(pal)+1); | UtilNCopyToLower((char*)palette, pal, strlen(pal)+1); | |||
skipping to change at line 3314 | skipping to change at line 3392 | |||
PYMOL_API_LOCK | PYMOL_API_LOCK | |||
if(ok) { | if(ok) { | |||
result.type = PYMOL_RETURN_VALUE_IS_STRING; | result.type = PYMOL_RETURN_VALUE_IS_STRING; | |||
result.string = mstrdup(_PyMOL_VERSION); | result.string = mstrdup(_PyMOL_VERSION); | |||
result.status = PyMOLstatus_SUCCESS; | result.status = PyMOLstatus_SUCCESS; | |||
}; | }; | |||
PYMOL_API_UNLOCK return result; | PYMOL_API_UNLOCK return result; | |||
} | } | |||
#ifndef _PYMOL_NOPY | ||||
AtomPropertyInfo *PyMOL_GetAtomPropertyInfo(CPyMOL * I, const char *atompropname ) | AtomPropertyInfo *PyMOL_GetAtomPropertyInfo(CPyMOL * I, const char *atompropname ) | |||
{ | { | |||
OVreturn_word result; | OVreturn_word result; | |||
if(!OVreturn_IS_OK((result = OVLexicon_BorrowFromCString(I->Lex, atompropname) ))) | if(!OVreturn_IS_OK((result = OVLexicon_BorrowFromCString(I->Lex, atompropname) ))) | |||
return NULL; | return NULL; | |||
result = OVOneToOne_GetForward(I->AtomPropertyLexicon, result.word); | result = OVOneToOne_GetForward(I->AtomPropertyLexicon, result.word); | |||
if(!OVreturn_IS_OK(result)) | if(!OVreturn_IS_OK(result)) | |||
return NULL; | return NULL; | |||
return &I->AtomPropertyInfos[result.word]; | return &I->AtomPropertyInfos[result.word]; | |||
} | } | |||
#endif | ||||
#ifdef __cplusplus | #ifdef __cplusplus | |||
} | } | |||
#endif | #endif | |||
End of changes. 75 change blocks. | ||||
131 lines changed or deleted | 214 lines changed or added |