Пример #1
0
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
}
Пример #2
0
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
}
Пример #3
0
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
}
Пример #4
0
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
}
Пример #5
0
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
}
Пример #6
0
/*========================================================================*/
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
}
Пример #7
0
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
}
Пример #8
0
/*========================================================================*/
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
}
Пример #9
0
Файл: Menu.c Проект: Almad/pymol
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
}