1 
2 
3 /*
4 A* -------------------------------------------------------------------
5 B* This file contains source code for the PyMOL computer program
6 C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
7 D* -------------------------------------------------------------------
8 E* It is unlawful to modify or remove this copyright notice.
9 F* -------------------------------------------------------------------
10 G* Please see the accompanying LICENSE file for further information.
11 H* -------------------------------------------------------------------
12 I* Additional authors of this source file include:
13 -*
14 -*
15 -*
16 Z* -------------------------------------------------------------------
17 */
18 #include"os_python.h"
19 
20 #include"os_predef.h"
21 
22 #include"os_std.h"
23 
24 #include "Menu.h"
25 #include "PopUp.h"
26 #include "P.h"
27 #include "Ortho.h"
28 
MenuActivate(PyMOLGlobals * G,int x,int y,int last_x,int last_y,int passive,const char * name,const char * sele)29 void MenuActivate(PyMOLGlobals * G, int x, int y, int last_x, int last_y, int passive,
30                   const char *name, const char *sele)
31 {
32 #ifndef _PYMOL_NOPY
33   PyObject *list;
34 
35   PBlock(G);
36 
37   list = PYOBJECT_CALLMETHOD(P_menu, name, "Os", G->P_inst->cmd, sele);
38   if(PyErr_Occurred())
39     PyErr_Print();
40   if(list) {
41     PopUpNew(G, x, y, last_x, last_y, passive, list, NULL);
42     Py_DECREF(list);
43   }
44   PUnblock(G);
45 #endif
46 
47 }
48 
MenuActivate3fv(PyMOLGlobals * G,int x,int y,int last_x,int last_y,int passive,const char * name,const float * xyz)49 void MenuActivate3fv(PyMOLGlobals * G, int x, int y, int last_x, int last_y, int passive,
50                      const char *name, const float *xyz)
51 {
52 #ifndef _PYMOL_NOPY
53   PyObject *list;
54 
55   PBlock(G);
56 
57   list =
58     PYOBJECT_CALLMETHOD(P_menu, name, "O(fff)(ii)", G->P_inst->cmd,
59         xyz[0], xyz[1], xyz[2], x, y);
60   if(PyErr_Occurred())
61     PyErr_Print();
62   if(list) {
63     PopUpNew(G, x, y, last_x, last_y, passive, list, NULL);
64     Py_DECREF(list);
65   }
66   PUnblock(G);
67 #endif
68 }
69 
MenuActivate2Arg(PyMOLGlobals * G,int x,int y,int last_x,int last_y,int passive,const char * name,const char * sele1,const char * sele2)70 void MenuActivate2Arg(PyMOLGlobals * G, int x, int y, int last_x, int last_y, int passive,
71                       const char *name, const char *sele1, const char *sele2)
72 {
73 #ifndef _PYMOL_NOPY
74   PyObject *list;
75 
76   PBlock(G);
77 
78   list = PYOBJECT_CALLMETHOD(P_menu, name, "Oss", G->P_inst->cmd, sele1, sele2);
79   if(PyErr_Occurred())
80     PyErr_Print();
81   if(list) {
82     PopUpNew(G, x, y, last_x, last_y, passive, list, NULL);
83     Py_DECREF(list);
84   }
85   PUnblock(G);
86 #endif
87 }
88 
MenuActivate1Arg(PyMOLGlobals * G,int x,int y,int last_x,int last_y,int passive,const char * name,const char * arg1)89 Block *MenuActivate1Arg(PyMOLGlobals * G, int x, int y, int last_x, int last_y, int passive,
90 			const char *name, const char *arg1)
91 {
92   Block *block = NULL;
93 #ifndef _PYMOL_NOPY
94   PyObject *list;
95   PBlock(G);
96 
97   list = PYOBJECT_CALLMETHOD(P_menu, name, "Os", G->P_inst->cmd, arg1);
98   if(PyErr_Occurred())
99     PyErr_Print();
100   if(list) {
101     block = PopUpNew(G, x, y, last_x, last_y, passive, list, NULL);
102     Py_DECREF(list);
103   }
104   PUnblock(G);
105 #endif
106   return block;
107 }
108 
MenuActivate0Arg(PyMOLGlobals * G,int x,int y,int last_x,int last_y,int passive,const char * name)109 void MenuActivate0Arg(PyMOLGlobals * G, int x, int y, int last_x, int last_y, int passive,
110                       const char *name)
111 {
112 #ifndef _PYMOL_NOPY
113   PyObject *list;
114 
115   PBlock(G);
116 
117   list = PYOBJECT_CALLMETHOD(P_menu, (char*)name, "O", G->P_inst->cmd);
118   if(PyErr_Occurred())
119     PyErr_Print();
120   if(list) {
121     PopUpNew(G, x, y, last_x, last_y, passive, list, NULL);
122     Py_DECREF(list);
123   }
124   PUnblock(G);
125 #endif
126 }
127