Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

AtomSel.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: AtomSel.h,v $
00013  *      $Author: johns $        $Locker:  $                $State: Exp $
00014  *      $Revision: 1.62 $      $Date: 2022/01/21 08:10:53 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  * 
00019  * Parse and maintain the data for selecting atoms.
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   // prevent use of these methods.
00051   AtomSel& operator=(const AtomSel &) { return *this; }
00052 //  AtomSel(AtomSel &) : ID(-1) {}
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, /* const */ 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     // eliminate branching when either all atoms are selected or when
00113     // we have a contiguous segment of selected atoms
00114     if ((selected == num_atoms) || ((lastsel-firstsel+1) == selected)) {
00115       for (int i=firstsel; i<=lastsel; i++) {
00116         function(i); // call lambda expression with selected atom
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         // loop and test all of the atoms in block[blk]
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         // eliminate branching when either all atoms are selected or when
00131         // we have a contiguous segment of selected atoms
00132         if (blkcount == 256 || ((lastatom-firstatom+1) == blkcount)) {
00133           for (int i=firstatom; i<=lastatom; i++) {
00134             function(i); // call lambda expression with selected atom
00135           }
00136         } else {
00137           for (int i=firstatom; i<=lastatom; i++) {
00138             if (on[i]) {
00139               function(i); // call lambda expression with selected atom
00140             }
00141           }
00142         }
00143 #else
00144         // loop and test all of the atoms in block[blk]
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); // call lambda expression with selected atom
00150           }
00151         }
00152 #endif
00153       }
00154 #endif
00155     } else {
00156       for (int i=firstsel; i<=lastsel; i++) {
00157         if (on[i]) {
00158           function(i); // call lambda expression with selected atom
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 

Generated on Thu Apr 25 02:41:58 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002