int WizardDoSpecial(PyMOLGlobals * G, int k, int x, int y, int mod) { #ifdef _PYMOL_NOPY return 0; #else register CWizard *I = G->Wizard; int result = false; if(I->EventMask & cWizEventSpecial) if(I->Stack >= 0) if(I->Wiz[I->Stack]) { OrthoLineType buffer; sprintf(buffer, "cmd.get_wizard().do_special(%d,%d,%d,%d)", k, x, y, mod); PLog(G, buffer, cPLog_pym); PBlock(G); if(I->Stack >= 0) if(I->Wiz[I->Stack]) { if(PyObject_HasAttrString(I->Wiz[I->Stack], "do_special")) { result = PTruthCallStr4i(I->Wiz[I->Stack], "do_special", k, x, y, mod); if(PyErr_Occurred()) PyErr_Print(); } } PUnblock(G); } return result; #endif }
int WizardDoDirty(PyMOLGlobals * G) { #ifdef _PYMOL_NOPY return 0; #else register CWizard *I = G->Wizard; int result = false; if(I->EventMask & cWizEventDirty) if(I->Stack >= 0) if(I->Wiz[I->Stack]) { OrthoLineType buffer; sprintf(buffer, "cmd.get_wizard().do_dirty()"); PLog(G, buffer, cPLog_pym); PBlock(G); if(I->Stack >= 0) if(I->Wiz[I->Stack]) { if(PyObject_HasAttrString(I->Wiz[I->Stack], "do_dirty")) { result = PTruthCallStr0(I->Wiz[I->Stack], "do_dirty"); if(PyErr_Occurred()) PyErr_Print(); } } PUnblock(G); } return result; #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 }
int WizardDoView(PyMOLGlobals * G, int force) { #ifdef _PYMOL_NOPY return 0; #else register CWizard *I = G->Wizard; int result = false; if(I->EventMask & cWizEventView) if(I->Stack >= 0) if(I->Wiz[I->Stack]) { int changed = force; if(!changed) { SceneViewType view; SceneGetView(G, view); changed = !SceneViewEqual(view, I->LastUpdatedView); } if(changed) { SceneGetView(G, I->LastUpdatedView); PBlock(G); if(I->Stack >= 0) if(I->Wiz[I->Stack]) { if(PyObject_HasAttrString(I->Wiz[I->Stack], "do_view")) { result = PTruthCallStr0(I->Wiz[I->Stack], "do_view"); if(PyErr_Occurred()) PyErr_Print(); } } PUnblock(G); } } return result; #endif }
int WizardDoPosition(PyMOLGlobals * G, int force) { #ifdef _PYMOL_NOPY return 0; #else register CWizard *I = G->Wizard; int result = false; if(I->EventMask & cWizEventPosition) if(I->Stack >= 0) if(I->Wiz[I->Stack]) { int changed = force; if(!changed) { float pos[3]; SceneGetCenter(G, pos); changed = ((fabs(pos[0] - I->LastUpdatedPosition[0]) > R_SMALL4) || (fabs(pos[1] - I->LastUpdatedPosition[1]) > R_SMALL4) || (fabs(pos[2] - I->LastUpdatedPosition[2]) > R_SMALL4)); } if(changed) { SceneGetCenter(G, I->LastUpdatedPosition); PBlock(G); if(I->Stack >= 0) if(I->Wiz[I->Stack]) { if(PyObject_HasAttrString(I->Wiz[I->Stack], "do_position")) { result = PTruthCallStr0(I->Wiz[I->Stack], "do_position"); if(PyErr_Occurred()) PyErr_Print(); } } PUnblock(G); } } return result; #endif }
/*========================================================================*/ int WizardDoPick(PyMOLGlobals * G, int bondFlag) { /** * Run when user picks something */ #ifdef _PYMOL_NOPY return 0; #else register CWizard *I = G->Wizard; int result = false; /* process the pick if it happened and we're listening for it */ if(I->EventMask & cWizEventPick) if(I->Stack >= 0) if(I->Wiz[I->Stack]) { if(bondFlag) PLog(G, "cmd.get_wizard().do_pick(1)", cPLog_pym); else PLog(G, "cmd.get_wizard().do_pick(0)", cPLog_pym); PBlock(G); if(I->Stack >= 0) if(I->Wiz[I->Stack]) { if(PyObject_HasAttrString(I->Wiz[I->Stack], "do_pick")) { result = PTruthCallStr1i(I->Wiz[I->Stack], "do_pick", bondFlag); if(PyErr_Occurred()) PyErr_Print(); } } PUnblock(G); } return result; #endif }
int WizardDoSelect(PyMOLGlobals * G, char *name) { /** * Run when user selects something with the mouse, in a wizard */ #ifdef _PYMOL_NOPY return 0; #else /* grab 'this' */ OrthoLineType buf; register CWizard *I = G->Wizard; int result = false; /* if the event is a selection and we're listening for selections */ if(I->EventMask & cWizEventSelect) if(I->Stack >= 0) if(I->Wiz[I->Stack]) { /* log if necessary */ sprintf(buf, "cmd.get_wizard().do_select('''%s''')", name); PLog(G, buf, cPLog_pym); /* block and call (in Python) the wizard's do_select */ PBlock(G); if(PyObject_HasAttrString(I->Wiz[I->Stack], "do_select")) { result = PTruthCallStr(I->Wiz[I->Stack], "do_select", name); 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 }
void MenuActivate1Arg(PyMOLGlobals * G, int x, int y, int last_x, int last_y, int passive, char *name, char *arg1) { #ifndef _PYMOL_NOPY PyObject *list; PBlock(G); list = PyObject_CallMethod(P_menu, name, "Os", G->P_inst->cmd, arg1); if(PyErr_Occurred()) PyErr_Print(); if(list) { PopUpNew(G, x, y, last_x, last_y, passive, list, NULL); Py_DECREF(list); } PUnblock(G); #endif }
//parse a block char* Block(int v){ lex++; int vars = v; char* ident = malloc(sizeof(char*) * 12); int number; int tmp; int jaddr; int bgn; int procvars; //store our constants if(!strcmp(token, "const")){ do{ Get(); if(!strcmp(token, "2")){ ident = input[tptr++]; } else{ Error(4); } Get(); if(!strcmp(token, "=")){ Get(); if(!strcmp(token, "3")) number = atoi(input[tptr++]); else Error(2); } else{ Error(3); } tmp = Add(st, ident, 0, number, -1, lex); if(tmp == 0); else printf("Error inserting %d into table. Code - %d\n",number, tmp); Get(); } while(!strcmp(token, ",")); if(!strcmp(token, ";")) Get(); else { Error(10); } } //store our variables if(!strcmp(token, "var")){ do{ Get(); if(!strcmp(token, "2")){ ident = input[tptr++]; } else{ Error(4); } tmp = Add(st, ident, 1, number, offset++, lex); if(tmp == 0); else printf("Error inserting %d into table. Code - %d\n",number, tmp); Get(); vars++; }while(!strcmp(token, ",")); if(!strcmp(token, ";")) Get(); else { Error(10); } } //allocate our stack space for our constants and variables bgn = line; Gen(7, 0, line); //parse all procedures while(!strcmp(token, "procedure")){ procvars = 0; offset = 4; Get(); if(!strcmp(token, "2")){ ident = input[tptr++]; Get(); } else{ Error(4); } procvars = PBlock(); if(!strcmp(token, ";")) Get(); else Error(6); Add(st, ident, 2, 0, line, lex); Add(st, "return", 1, 0, 0, lex+1); Block(procvars); if(!strcmp(token, ";")) Get(); else{ Error(10); } Gen(2,0,0); } codegen[bgn].m = line; Gen(6, 0, vars + 4); Statement(); Delete(st); lex--; return token; }