int WizardUpdate(PyMOLGlobals * G) { register CWizard *I = G->Wizard; int result = false; if(OrthoGetDirty(G)) { WizardDoDirty(G); } { int frame = SettingGetGlobal_i(G, cSetting_frame); if(frame != I->LastUpdatedFrame) { I->LastUpdatedFrame = frame; WizardDoFrame(G); } } { int state = SettingGetGlobal_i(G, cSetting_state); if(state != I->LastUpdatedState) { I->LastUpdatedState = state; WizardDoState(G); } } WizardDoPosition(G, false); WizardDoView(G, false); if(I->Dirty) { WizardRefresh(G); I->Dirty = false; result = true; } return result; }
/*========================================================================*/ static int WizardRelease(Block * block, int button, int x, int y, int mod) { PyMOLGlobals *G = block->G; register CWizard *I = G->Wizard; int LineHeight = SettingGetGlobal_i(G, cSetting_internal_gui_control_size); int a; a = ((I->Block->rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / LineHeight; if(I->Pressed) I->Pressed = -1; OrthoDirty(G); OrthoUngrab(G); if((a >= 0) && ((ov_size) a < I->NLine)) { switch (I->Line[a].type) { case cWizTypeButton: if(I->Stack >= 0) if(I->Wiz[I->Stack]) { PLog(G, I->Line[a].code, cPLog_pym); PParse(G, I->Line[a].code); PFlush(G); } break; } } I->Pressed = -1; return (1); }
/*========================================================================*/ static int WizardDrag(Block * block, int x, int y, int mod) { #ifdef _PYMOL_NOPY return 0; #else PyMOLGlobals *G = block->G; register CWizard *I = G->Wizard; int LineHeight = SettingGetGlobal_i(G, cSetting_internal_gui_control_size); int a; a = ((I->Block->rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / LineHeight; if((x < I->Block->rect.left) || (x > I->Block->rect.right)) a = -1; if(I->Pressed != a) { I->Pressed = -1; OrthoDirty(G); } if((a >= 0) && ((ov_size) a < I->NLine)) { switch (I->Line[a].type) { case cWizTypeButton: if(I->Pressed != a) { I->Pressed = a; OrthoDirty(G); } break; } } return (1); #endif }
int WizardDoFrame(PyMOLGlobals * G) { #ifdef _PYMOL_NOPY return 0; #else register CWizard *I = G->Wizard; int result = false; if(I->EventMask & cWizEventFrame) if(I->Stack >= 0) if(I->Wiz[I->Stack]) { OrthoLineType buffer; int frame = SettingGetGlobal_i(G, cSetting_frame) + 1; sprintf(buffer, "cmd.get_wizard().do_frame(%d)", frame); PLog(G, buffer, cPLog_pym); PBlock(G); if(I->Stack >= 0) if(I->Wiz[I->Stack]) { if(PyObject_HasAttrString(I->Wiz[I->Stack], "do_frame")) { result = PTruthCallStr1i(I->Wiz[I->Stack], "do_frame", frame); if(PyErr_Occurred()) PyErr_Print(); } } PUnblock(G); } return result; #endif }
/*========================================================================*/ static int WizardClick(Block * block, int button, int x, int y, int mod) { #ifdef _PYMOL_NOPY return 0; #else PyMOLGlobals *G = block->G; register CWizard *I = G->Wizard; int a; PyObject *menuList = NULL; int LineHeight = SettingGetGlobal_i(G, cSetting_internal_gui_control_size); a = ((I->Block->rect.top - (y + cWizardClickOffset)) - cWizardTopMargin) / LineHeight; if((a >= 0) && ((ov_size) a < I->NLine)) { switch (I->Line[a].type) { case cWizTypeButton: OrthoGrab(G, I->Block); I->Pressed = (int) a; OrthoDirty(G); break; case cWizTypePopUp: PBlock(G); if(I->Stack >= 0) if(I->Wiz[I->Stack]) { if(PyObject_HasAttrString(I->Wiz[I->Stack], "get_menu")) { menuList = PyObject_CallMethod(I->Wiz[I->Stack], "get_menu", "s", I->Line[a].code); if(PyErr_Occurred()) PyErr_Print(); } } if(PyErr_Occurred()) PyErr_Print(); if(menuList && (menuList != Py_None)) { int my = I->Block->rect.top - (cWizardTopMargin + a * LineHeight) - 2; PopUpNew(G, x, my, x, y, false, menuList, NULL); } Py_XDECREF(menuList); PUnblock(G); break; } } return (1); #endif }
static void RepLabelRender(RepLabel * I, RenderInfo * info) { CRay *ray = info->ray; Picking **pick = info->pick; PyMOLGlobals *G = I->R.G; float *v = I->V; int c = I->N; int *l = I->L; int font_id = SettingGet_i(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_label_font_id); float font_size = SettingGet_f(G, I->R.cs->Setting, I->R.obj->Setting, cSetting_label_size); if(ray) { if(c) { char *st; TextSetOutlineColor(G, I->OutlineColor); while(c--) { if(*l) { st = OVLexicon_FetchCString(G->Lexicon, *l); TextSetPosNColor(G, v + 3, v); TextRenderRay(G, ray, font_id, st, font_size, v + 6); } v += 9; l++; } } } else if(G->HaveGUI && G->ValidContext) { if(pick) { Pickable *p = I->R.P; int i; if (I->shaderCGO){ CGORenderGLPicking(I->shaderCGO, pick, &I->R.context, I->R.cs->Setting, I->R.obj->Setting); return; } SceneSetupGLPicking(G); if(c) { char *st; int float_text = SettingGetGlobal_i(G, cSetting_float_labels); if(float_text) glDisable(GL_DEPTH_TEST); i = (*pick)->src.index; while(c--) { if(*l) { int first_pass = (!(*pick)[0].src.bond); i++; TextSetPosNColor(G, v + 3, v); TextSetPickColor(G, first_pass, i); if(first_pass) { VLACheck((*pick), Picking, i); p++; (*pick)[i].src = *p; /* copy object and atom info */ (*pick)[i].context = I->R.context; } st = OVLexicon_FetchCString(G->Lexicon, *l); TextRenderOpenGL(G, info, font_id, st, font_size, v + 6, SHADERCGO); } l++; v += 9; } if(float_text) glEnable(GL_DEPTH_TEST); (*pick)[0].src.index = i; /* pass the count */ } } else { if(c) { char *st; int float_text = SettingGetGlobal_i(G, cSetting_float_labels); short use_shader; Pickable *p = I->R.P; use_shader = SettingGetGlobal_b(G, cSetting_use_shaders); if(float_text) glDisable(GL_DEPTH_TEST); if (use_shader){ if (!I->shaderCGO){ I->shaderCGO = CGONew(G); if (use_shader){ I->shaderCGO->use_shader = true; I->shaderCGO->enable_shaders = true; } } else { CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); if(float_text) glEnable(GL_DEPTH_TEST); return; } } else if (I->shaderCGO) { CGOFree(I->shaderCGO); I->shaderCGO = NULL; } TextSetOutlineColor(G, I->OutlineColor); while(c--) { if(*l) { p++; if (I->shaderCGO) CGOPickColor(I->shaderCGO, p->index, p->bond); TextSetPosNColor(G, v + 3, v); st = OVLexicon_FetchCString(G->Lexicon, *l); TextRenderOpenGL(G, info, font_id, st, font_size, v + 6, SHADERCGO); } l++; v += 9; } if (I->shaderCGO){ CGO *convertcgo; CGOStop(I->shaderCGO); convertcgo = CGOOptimizeLabels(I->shaderCGO, 0); CGOFree(I->shaderCGO); I->shaderCGO = convertcgo; convertcgo = NULL; if (I->shaderCGO){ I->shaderCGO->use_shader = true; I->shaderCGO->enable_shaders = true; CGORenderGL(I->shaderCGO, NULL, NULL, NULL, info, &I->R); } } if(float_text) glEnable(GL_DEPTH_TEST); } } } }
/*========================================================================*/ void WizardRefresh(PyMOLGlobals * G) { #ifndef _PYMOL_NOPY register CWizard *I = G->Wizard; char *vla = NULL; PyObject *P_list; ov_size ll; PyObject *i; ov_size a; int blocked; blocked = PAutoBlock(G); /* get the current prompt */ if(I->Stack >= 0) if(I->Wiz[I->Stack]) { vla = NULL; if(PyObject_HasAttrString(I->Wiz[I->Stack], "get_prompt")) { P_list = PyObject_CallMethod(I->Wiz[I->Stack], "get_prompt", ""); if(PyErr_Occurred()) PyErr_Print(); if(P_list) PConvPyListToStringVLA(P_list, &vla); Py_XDECREF(P_list); } } OrthoSetWizardPrompt(G, vla); /* get the current panel list */ I->NLine = 0; if(I->Stack >= 0) if(I->Wiz[I->Stack]) { I->EventMask = cWizEventPick + cWizEventSelect; if(PyObject_HasAttrString(I->Wiz[I->Stack], "get_event_mask")) { i = PyObject_CallMethod(I->Wiz[I->Stack], "get_event_mask", ""); if(PyErr_Occurred()) PyErr_Print(); if(!PConvPyIntToInt(i, &I->EventMask)) I->EventMask = cWizEventPick + cWizEventSelect; Py_XDECREF(i); } if(PyObject_HasAttrString(I->Wiz[I->Stack], "get_panel")) { P_list = PyObject_CallMethod(I->Wiz[I->Stack], "get_panel", ""); if(PyErr_Occurred()) PyErr_Print(); if(P_list) { if(PyList_Check(P_list)) { ll = PyList_Size(P_list); VLACheck(I->Line, WizardLine, ll); for(a = 0; a < ll; a++) { /* fallback defaults */ I->Line[a].text[0] = 0; I->Line[a].code[0] = 0; I->Line[a].type = 0; i = PyList_GetItem(P_list, a); if(PyList_Check(i)) if(PyList_Size(i) > 2) { PConvPyObjectToInt(PyList_GetItem(i, 0), &I->Line[a].type); PConvPyObjectToStrMaxLen(PyList_GetItem(i, 1), I->Line[a].text, sizeof(WordType) - 1); PConvPyObjectToStrMaxLen(PyList_GetItem(i, 2), I->Line[a].code, sizeof(OrthoLineType) - 1); } } I->NLine = ll; } } Py_XDECREF(P_list); } } if(I->NLine) { int LineHeight = SettingGetGlobal_i(G, cSetting_internal_gui_control_size); OrthoReshapeWizard(G, LineHeight * I->NLine + 4); } else { OrthoReshapeWizard(G, 0); } PAutoUnblock(G, blocked); #endif }