MovieScene.cpp (pymol-open-source-2.2.0) | : | MovieScene.cpp (pymol-open-source-2.3.0) | ||
---|---|---|---|---|
skipping to change at line 151 | skipping to change at line 151 | |||
std::vector<std::string> new_order; | std::vector<std::string> new_order; | |||
bool is_all = false; | bool is_all = false; | |||
if (strcmp("*", names) == 0) { | if (strcmp("*", names) == 0) { | |||
is_all = true; | is_all = true; | |||
names_list = G->scenes->order; | names_list = G->scenes->order; | |||
} else { | } else { | |||
names_list = strsplit(names); | names_list = strsplit(names); | |||
// check that all given names are existing scenes | // check that all given names are existing scenes | |||
for (auto it = names_list.begin(); it != names_list.end(); ++it) { | for (auto& name : names_list) { | |||
if (G->scenes->dict.find(*it) == G->scenes->dict.end()) { | if (G->scenes->dict.find(name) == G->scenes->dict.end()) { | |||
PRINTFB(G, FB_Scene, FB_Errors) | PRINTFB(G, FB_Scene, FB_Errors) | |||
" Error: scene '%s' is not defined.\n", it->c_str() ENDFB(G); | " Error: scene '%s' is not defined.\n", name.c_str() ENDFB(G); | |||
return false; | return false; | |||
} | } | |||
} | } | |||
} | } | |||
if (names_list.empty()) { | if (names_list.empty()) { | |||
return true; | return true; | |||
} | } | |||
if (sort) { | if (sort) { | |||
skipping to change at line 193 | skipping to change at line 193 | |||
if (loc != 't' && loc != 'c' && loc != 'b') { | if (loc != 't' && loc != 'c' && loc != 'b') { | |||
PRINTFB(G, FB_Scene, FB_Errors) | PRINTFB(G, FB_Scene, FB_Errors) | |||
" Error: invalid location '%s'.\n", location ENDFB(G); | " Error: invalid location '%s'.\n", location ENDFB(G); | |||
return false; | return false; | |||
} | } | |||
if (loc == 't' /* top */) { | if (loc == 't' /* top */) { | |||
new_order.insert(new_order.end(), names_list.begin(), names_list.end()); | new_order.insert(new_order.end(), names_list.begin(), names_list.end()); | |||
} | } | |||
for (auto it = G->scenes->order.begin(); it != G->scenes->order.end(); ++it) | for (auto& name : G->scenes->order) { | |||
{ | if (!names_set.count(name)) { | |||
if (!names_set.count(*it)) { | new_order.push_back(name); | |||
new_order.push_back(*it); | } else if (loc == 'c' /* current */ && name == names_list[0]) { | |||
} else if (loc == 'c' /* current */ && *it == names_list[0]) { | ||||
new_order.insert(new_order.end(), names_list.begin(), names_list.end()); | new_order.insert(new_order.end(), names_list.begin(), names_list.end()); | |||
} | } | |||
} | } | |||
if (loc == 'b' /* bottom */) { | if (loc == 'b' /* bottom */) { | |||
new_order.insert(new_order.end(), names_list.begin(), names_list.end()); | new_order.insert(new_order.end(), names_list.begin(), names_list.end()); | |||
} | } | |||
} | } | |||
G->scenes->order = new_order; | G->scenes->order = new_order; | |||
skipping to change at line 475 | skipping to change at line 475 | |||
// "enabled" state is first bit in visRep | // "enabled" state is first bit in visRep | |||
int enabled = GET_BIT(sceneobj.visRep, 0); | int enabled = GET_BIT(sceneobj.visRep, 0); | |||
if(recall_active && enabled) { | if(recall_active && enabled) { | |||
// need to control SpecRec | // need to control SpecRec | |||
ExecutiveSetObjVisib(G, obj->Name, enabled, false); | ExecutiveSetObjVisib(G, obj->Name, enabled, false); | |||
} | } | |||
} | } | |||
// invalidate | // invalidate | |||
for (auto it = objectstoinvalidate.begin(); | for (auto& item : objectstoinvalidate) { | |||
it != objectstoinvalidate.end(); ++it) { | item.first->invalidate(cRepAll, item.second ? cRepInvVisib : cRepInvColor, - | |||
it->first->invalidate(cRepAll, it->second ? cRepInvVisib : cRepInvColor, -1) | 1); | |||
; | ||||
} | } | |||
// camera view | // camera view | |||
if (recall_view) { | if (recall_view) { | |||
if (animate < -0.5) // == -1 | if (animate < -0.5) // == -1 | |||
animate = get_scene_animation_duration(G); | animate = get_scene_animation_duration(G); | |||
SceneSetView(G, scene.view, true, animate, 1); | SceneSetView(G, scene.view, true, animate, 1); | |||
} | } | |||
skipping to change at line 505 | skipping to change at line 504 | |||
return true; | return true; | |||
} | } | |||
/* | /* | |||
* Rename or delete a scene | * Rename or delete a scene | |||
* | * | |||
* name: name to rename or delete, or "*" to delete all | * name: name to rename or delete, or "*" to delete all | |||
* new_name: new scene name to rename, or NULL to delete | * new_name: new scene name to rename, or NULL to delete | |||
*/ | */ | |||
static bool MovieSceneRename(PyMOLGlobals * G, const char * name, const char * n ew_name = NULL) { | static bool MovieSceneRename(PyMOLGlobals * G, const char * name, const char * n ew_name = nullptr) { | |||
if (strcmp(name, "*") == 0) { | if (strcmp(name, "*") == 0) { | |||
// delete all scenes | // delete all scenes | |||
G->scenes->dict.clear(); | G->scenes->dict.clear(); | |||
G->scenes->order.clear(); | G->scenes->order.clear(); | |||
SceneSetNames(G, G->scenes->order); | SceneSetNames(G, G->scenes->order); | |||
return true; | return true; | |||
} | } | |||
if (!new_name) { | if (!new_name) { | |||
skipping to change at line 624 | skipping to change at line 623 | |||
} | } | |||
return it->c_str(); | return it->c_str(); | |||
} | } | |||
/* | /* | |||
* Move the current scene (scene_current_name) before or after "key" | * Move the current scene (scene_current_name) before or after "key" | |||
*/ | */ | |||
static bool MovieSceneOrderBeforeAfter(PyMOLGlobals * G, const char * key, bool before) | static bool MovieSceneOrderBeforeAfter(PyMOLGlobals * G, const char * key, bool before) | |||
{ | { | |||
const char * location = NULL; | const char * location = nullptr; | |||
const char * key2 = SettingGetGlobal_s(G, cSetting_scene_current_name); | const char * key2 = SettingGetGlobal_s(G, cSetting_scene_current_name); | |||
if (before) { | if (before) { | |||
auto it = std::find(G->scenes->order.begin(), G->scenes->order.end(), key); | auto it = std::find(G->scenes->order.begin(), G->scenes->order.end(), key); | |||
if (it == G->scenes->order.begin()) { | if (it == G->scenes->order.begin()) { | |||
location = "top"; | location = "top"; | |||
key = ""; | key = ""; | |||
} else { | } else { | |||
key = (it - 1)->c_str(); | key = (it - 1)->c_str(); | |||
} | } | |||
skipping to change at line 719 | skipping to change at line 718 | |||
} else if (strcmp(action, "store") == 0) { | } else if (strcmp(action, "store") == 0) { | |||
status = MovieSceneStore(G, key, message, store_view, store_color, | status = MovieSceneStore(G, key, message, store_view, store_color, | |||
store_active, store_rep, store_frame, sele); | store_active, store_rep, store_frame, sele); | |||
// insert_before, insert_after | // insert_before, insert_after | |||
if (status && beforeafter) | if (status && beforeafter) | |||
status = MovieSceneOrderBeforeAfter(G, prev_name.c_str(), beforeafter == 1 ); | status = MovieSceneOrderBeforeAfter(G, prev_name.c_str(), beforeafter == 1 ); | |||
} else if (strcmp(action, "delete") == 0) { | } else if (strcmp(action, "delete") == 0) { | |||
status = MovieSceneRename(G, key, NULL); | status = MovieSceneRename(G, key, nullptr); | |||
} else if (strcmp(action, "rename") == 0) { | } else if (strcmp(action, "rename") == 0) { | |||
status = MovieSceneRename(G, key, new_key); | status = MovieSceneRename(G, key, new_key); | |||
} else if (strcmp(action, "order") == 0) { | } else if (strcmp(action, "order") == 0) { | |||
status = MovieSceneOrder(G, key); | status = MovieSceneOrder(G, key); | |||
} else if (strcmp(action, "sort") == 0) { | } else if (strcmp(action, "sort") == 0) { | |||
status = MovieSceneOrder(G, key, true); | status = MovieSceneOrder(G, key, true); | |||
} else if (strcmp(action, "first") == 0) { | } else if (strcmp(action, "first") == 0) { | |||
status = MovieSceneOrder(G, key, false, "top"); | status = MovieSceneOrder(G, key, false, "top"); | |||
} else { | } else { | |||
PRINTFB(G, FB_Scene, FB_Errors) | PRINTFB(G, FB_Scene, FB_Errors) | |||
" Error: invalid action '%s'\n", action ENDFB(G); | " Error: invalid action '%s'\n", action ENDFB(G); | |||
} | } | |||
// trigger GUI updates (scene buttons, Tcl/Tk menu) | // trigger GUI updates (scene buttons, Tcl/Tk menu) | |||
SettingSetGlobal_b(G, cSetting_scenes_changed, 1); | SettingSetGlobal_b(G, cSetting_scenes_changed, true); | |||
SettingGenerateSideEffects(G, cSetting_scenes_changed, NULL, 0, true); | SettingGenerateSideEffects(G, cSetting_scenes_changed, nullptr, 0, true); | |||
return status; | return status; | |||
ok_exceptNOSCENES: | ok_exceptNOSCENES: | |||
PRINTFB(G, FB_Scene, FB_Errors) | PRINTFB(G, FB_Scene, FB_Errors) | |||
" Error: no scenes\n" ENDFB(G); | " Error: no scenes\n" ENDFB(G); | |||
return false; | return false; | |||
} | } | |||
/* | /* | |||
skipping to change at line 757 | skipping to change at line 756 | |||
*/ | */ | |||
void MovieScenesInit(PyMOLGlobals * G) { | void MovieScenesInit(PyMOLGlobals * G) { | |||
MovieScenesFree(G); | MovieScenesFree(G); | |||
G->scenes = new CMovieScenes; | G->scenes = new CMovieScenes; | |||
} | } | |||
void MovieScenesFree(PyMOLGlobals * G) { | void MovieScenesFree(PyMOLGlobals * G) { | |||
if (G->scenes) { | if (G->scenes) { | |||
delete G->scenes; | delete G->scenes; | |||
G->scenes = NULL; | G->scenes = nullptr; | |||
} | } | |||
} | } | |||
/* | /* | |||
* PConvToPyObject/PConvFromPyObject | * PConvToPyObject/PConvFromPyObject | |||
* | * | |||
* Convertion to/from Python objects for all MovieScene types | * Convertion to/from Python objects for all MovieScene types | |||
*/ | */ | |||
static PyObject * PConvToPyObject(const MovieSceneAtom &v) { | static PyObject * PConvToPyObject(const MovieSceneAtom &v) { | |||
skipping to change at line 787 | skipping to change at line 786 | |||
PyList_SET_ITEM(obj, 0, PConvToPyObject(v.storemask)); | PyList_SET_ITEM(obj, 0, PConvToPyObject(v.storemask)); | |||
PyList_SET_ITEM(obj, 1, PConvToPyObject(v.frame)); | PyList_SET_ITEM(obj, 1, PConvToPyObject(v.frame)); | |||
PyList_SET_ITEM(obj, 2, PConvToPyObject(v.message.c_str())); | PyList_SET_ITEM(obj, 2, PConvToPyObject(v.message.c_str())); | |||
PyList_SET_ITEM(obj, 3, PConvToPyObject(v.view, cSceneViewSize)); | PyList_SET_ITEM(obj, 3, PConvToPyObject(v.view, cSceneViewSize)); | |||
PyList_SET_ITEM(obj, 4, PConvToPyObject(v.atomdata)); | PyList_SET_ITEM(obj, 4, PConvToPyObject(v.atomdata)); | |||
PyList_SET_ITEM(obj, 5, PConvToPyObject(v.objectdata)); | PyList_SET_ITEM(obj, 5, PConvToPyObject(v.objectdata)); | |||
return obj; | return obj; | |||
} | } | |||
static bool PConvFromPyObject(PyMOLGlobals *, PyObject * obj, MovieSceneAtom &ou t) { | static bool PConvFromPyObject(PyMOLGlobals *, PyObject * obj, MovieSceneAtom &ou t) { | |||
return PConvArgsFromPyList(NULL, obj, out.color, out.visRep); | return PConvArgsFromPyList(nullptr, obj, out.color, out.visRep); | |||
} | } | |||
static bool PConvFromPyObject(PyMOLGlobals *, PyObject * obj, MovieSceneObject & out) { | static bool PConvFromPyObject(PyMOLGlobals *, PyObject * obj, MovieSceneObject & out) { | |||
return PConvArgsFromPyList(NULL, obj, out.color, out.visRep); | return PConvArgsFromPyList(nullptr, obj, out.color, out.visRep); | |||
} | } | |||
static bool PConvFromPyObject(PyMOLGlobals * G, PyObject * obj, MovieScene &out) { | static bool PConvFromPyObject(PyMOLGlobals * G, PyObject * obj, MovieScene &out) { | |||
std::map<int, MovieSceneAtom> atomdata_old_ids; | std::map<int, MovieSceneAtom> atomdata_old_ids; | |||
if (!G) { | if (!G) { | |||
printf(" Error: G is NULL\n"); | printf(" Error: G is NULL\n"); | |||
return false; | return false; | |||
} | } | |||
if (!PConvArgsFromPyList(NULL, obj, | if (!PConvArgsFromPyList(nullptr, obj, | |||
out.storemask, | out.storemask, | |||
out.frame, | out.frame, | |||
out.message, | out.message, | |||
out.view, | out.view, | |||
atomdata_old_ids, | atomdata_old_ids, | |||
out.objectdata)) | out.objectdata)) | |||
/* ignore */; | /* ignore */; | |||
// restore atomdata dict but with converted ids | // restore atomdata dict but with converted ids | |||
PConvFromPyObject(G, PyList_GetItem(obj, 4), atomdata_old_ids); | PConvFromPyObject(G, PyList_GetItem(obj, 4), atomdata_old_ids); | |||
for (auto it = atomdata_old_ids.begin(); it != atomdata_old_ids.end(); ++it) { | for (auto& item : atomdata_old_ids) { | |||
int unique_id = SettingUniqueConvertOldSessionID(G, it->first); | int unique_id = SettingUniqueConvertOldSessionID(G, item.first); | |||
std::swap(out.atomdata[unique_id], it->second); | std::swap(out.atomdata[unique_id], item.second); | |||
} | } | |||
return true; | return true; | |||
} | } | |||
/* | /* | |||
* For get_session | * For get_session | |||
*/ | */ | |||
PyObject * MovieScenesAsPyList(PyMOLGlobals * G) { | PyObject * MovieScenesAsPyList(PyMOLGlobals * G) { | |||
End of changes. 13 change blocks. | ||||
24 lines changed or deleted | 22 lines changed or added |