Example #1
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
}
Example #2
0
/*========================================================================*/
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);
}
Example #3
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
}
Example #4
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
}
Example #5
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
}
Example #6
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
}
Example #7
0
static int ControlRelease(Block * block, int button, int x, int y, int mod)
{
  PyMOLGlobals *G = block->G;
  register CControl *I = G->Control;

  int sel = 0;

  I->LastPos = x;
  sel = which_button(I, x, y);
  if(!I->SkipRelease) {
    switch (sel) {
    case 0:
      SceneSetFrame(G, 4, 0);
      PLog(G, "cmd.rewind()", cPLog_pym);
      break;
    case 1:
      SceneSetFrame(G, 5, -1);
      PLog(G, "cmd.back()", cPLog_pym);
      break;
    case 2:
      MoviePlay(G, cMovieStop);
      if(SettingGet(G, cSetting_sculpting))
        SettingSet(G, cSetting_sculpting, 0);
      if(SettingGetGlobal_b(G, cSetting_rock))
        SettingSetGlobal_b(G, cSetting_rock, false);
      ExecutiveDrawNow(G);
      OrthoDirty(G);
      PLog(G, "cmd.mstop()", cPLog_pym);
      break;
    case 3:
      if(!MoviePlaying(G)) {
        if(mod & cOrthoCTRL) {
          PLog(G, "cmd.rewind()", cPLog_pym);
          PLog(G, "cmd.mplay()", cPLog_pym);
          SceneSetFrame(G, 4, 0);
          MoviePlay(G, cMoviePlay);
        } else {
          PLog(G, "cmd.mplay()", cPLog_pym);
          MoviePlay(G, cMoviePlay);
        }
      } else {
        MoviePlay(G, cMovieStop);
        ExecutiveDrawNow(G);
        OrthoDirty(G);
        PLog(G, "cmd.mstop()", cPLog_pym);
      }
      break;
    case 4:
      SceneSetFrame(G, 5, 1);
      PLog(G, "cmd.forward()", cPLog_pym);
      break;
    case 5:
      if(mod & cOrthoCTRL) {
        SceneSetFrame(G, 3, 0);
        PLog(G, "cmd.middle()", cPLog_pym);
      } else {
        SceneSetFrame(G, 6, 0);
        PLog(G, "cmd.ending()", cPLog_pym);
      }
      break;
    case 6:
      if(SettingGetGlobal_b(G, cSetting_seq_view)) {
        SettingSetGlobal_b(G, cSetting_seq_view, 0);
        SeqChanged(G);
        PLog(G, "cmd.set('seq_view',0)", cPLog_pym);
      } else {
        SettingSetGlobal_b(G, cSetting_seq_view, 1);
        SeqChanged(G);
        PLog(G, "cmd.set('seq_view',1)", cPLog_pym);
      }
      OrthoDirty(G);
      break;
    case 7:
      SettingSetGlobal_b(G, cSetting_rock, !SettingGetGlobal_b(G, cSetting_rock));
      if(SettingGetGlobal_b(G, cSetting_rock)) {
        SceneRestartSweepTimer(G);
        PLog(G, "cmd.rock(1)", cPLog_pym);
      } else
        PLog(G, "cmd.rock(0)", cPLog_pym);
      SceneRestartFrameTimer(G);
      OrthoDirty(G);
      break;
    case 8:
      PLog(G, "cmd.fullscreen()", cPLog_pym);
      ExecutiveFullScreen(G, -1);
      break;
    }
    OrthoDirty(G);
    OrthoUngrab(G);
    I->LastClickTime = UtilGetSeconds(G);
    I->DragFlag = false;
    I->Active = -1;
    I->Pressed = -1;
  }
  return (1);
}