00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef ATOMSEL_H
00023 #define ATOMSEL_H
00024
00025 class MoleculeList;
00026 class DrawMolecule;
00027 class ParseTree;
00028 class SymbolTable;
00029 class Timestep;
00030 class VMDApp;
00031
00032 extern void atomSelParser_init(SymbolTable *);
00033
00035 struct atomsel_ctxt {
00036 SymbolTable *table;
00037 DrawMolecule *atom_sel_mol;
00038 int which_frame;
00039 const char *singleword;
00040 atomsel_ctxt(SymbolTable *s, DrawMolecule *d, int frame, const char *word)
00041 : table(s), atom_sel_mol(d), which_frame(frame), singleword(word) {}
00042 };
00043
00045 class AtomSel {
00046 private:
00047 VMDApp *app;
00048 ParseTree *tree;
00049
00050
00051 AtomSel& operator=(const AtomSel &) { return *this; }
00052
00053 const int ID;
00054 SymbolTable *table;
00055
00056 public:
00057 char *cmdStr;
00058 int molid() const { return ID; }
00059 int *on;
00060 unsigned int *on256;
00061 int num_atoms;
00062 int num_atoms256;
00063 int selected;
00064 int firstsel;
00065 int lastsel;
00066
00067 enum {TS_LAST = -2, TS_NOW = -1};
00068 int which_frame;
00069 int do_update;
00070
00071 AtomSel(VMDApp *vmdapp, SymbolTable *, int mymolid);
00072 ~AtomSel();
00073
00081 enum {NO_PARSE = -1, NO_EVAL=-2, PARSE_SUCCESS = 0};
00082
00089 int change(const char *newcmd, DrawMolecule *);
00090
00093 float *coordinates(MoleculeList *) const;
00094
00096 Timestep *timestep(MoleculeList *) const;
00097
00103 static int get_frame_value(const char *s, int *val);
00104
00105
00106 #if 0 && (__cplusplus >= 201103L)
00110 template <typename F>
00111 int for_selected_lambda(F function) const {
00112
00113
00114 if ((selected == num_atoms) || ((lastsel-firstsel+1) == selected)) {
00115 for (int i=firstsel; i<=lastsel; i++) {
00116 function(i);
00117 }
00118 #if 1
00119 } else if (on256 != NULL) {
00120 int firstblk = firstsel >> 8;
00121 int lastblk = lastsel >> 8;
00122 for (int blk=firstblk; blk<=lastblk; blk++) {
00123 #if 0
00124
00125 int blkstart = blk << 8;
00126 int firstatom = ((on256[blk] >> 8) & 0xFF) + blkstart;
00127 int lastatom = ((on256[blk] >> 16) & 0xFF) + blkstart;
00128 int blkcount = (on256[blk] & 0xFF);
00129
00130
00131
00132 if (blkcount == 256 || ((lastatom-firstatom+1) == blkcount)) {
00133 for (int i=firstatom; i<=lastatom; i++) {
00134 function(i);
00135 }
00136 } else {
00137 for (int i=firstatom; i<=lastatom; i++) {
00138 if (on[i]) {
00139 function(i);
00140 }
00141 }
00142 }
00143 #else
00144
00145 int firstatom = blk << 8;
00146 int lastatom = ((blk+1) << 8) - 1;
00147 for (int i=firstatom; i<=lastatom; i++) {
00148 if (on[i]) {
00149 function(i);
00150 }
00151 }
00152 #endif
00153 }
00154 #endif
00155 } else {
00156 for (int i=firstsel; i<=lastsel; i++) {
00157 if (on[i]) {
00158 function(i);
00159 }
00160 }
00161 }
00162
00163 return selected;
00164 }
00165 #endif
00166
00167
00168 };
00169
00171 int atomsel_custom_singleword(void *v, int num, int *flgs);
00172
00173 #endif
00174