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: DrawMolecule.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.88 $ $Date: 2020年10月28日 15:09:56 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * 00019 * Displayable version of a molecule, derived from BaseMolecule and 00020 * Displayable. This contains all the info for rendering the molecule. 00021 * 00022 ***************************************************************************/ 00023 #ifndef DRAWMOLECULE_H 00024 #define DRAWMOLECULE_H 00025 00026 #include "BaseMolecule.h" 00027 #include "Displayable.h" 00028 #include "DrawMolItem.h" 00029 #include "ResizeArray.h" 00030 #include "WKFThreads.h" 00031 #include "QuickSurf.h" 00032 00033 class AtomColor; 00034 class AtomRep; 00035 class AtomSel; 00036 class VMDApp; 00037 class MoleculeGraphics; 00038 class DrawForce; 00039 00040 // XXX this macro enables code to allow the molecular orbital 00041 // representations within the same molecule to reuse any existing 00042 // rep's molecular orbital grid if the orbital ID and various 00043 // grid-specific parameters are all compatible. This optimization 00044 // short-circuits the need for a rep to compute its own grid if 00045 // any other rep already has what it needs. For large QM/MM scenes, 00046 // this optimization can be worth as much as a 2X speedup when 00047 // orbital computation dominates animation performance. 00048 #define VMDENABLEORBITALGRIDBACKDOOR 1 00049 00052 class DrawMoleculeMonitor { 00053 public: 00054 // called with id of molecule 00055 virtual void notify(int) = 0; 00056 DrawMoleculeMonitor() {} 00057 virtual ~DrawMoleculeMonitor() {} 00058 }; 00059 00060 00062 class DrawMolecule : public BaseMolecule, public Displayable { 00063 public: 00064 int active; 00065 00066 VMDApp *app; 00067 00068 00069 00070 00071 private: 00072 int repcounter; 00073 00076 MoleculeGraphics *molgraphics; 00077 00079 DrawForce *drawForce; 00080 00081 #if defined(VMDENABLEORBITALGRIDBACKDOOR) 00084 public: 00085 #endif 00086 00087 ResizeArray<DrawMolItem *> repList; 00088 00089 #if defined(VMDENABLEORBITALGRIDBACKDOOR) 00092 private: 00093 #endif 00094 00095 ResizeArray<Timestep *> timesteps; 00096 00098 int curframe; 00099 00102 int did_secondary_structure; 00103 00105 ResizeArray<DrawMoleculeMonitor *> monitorlist; 00106 00108 void addremove_ts(); 00109 00110 float center[3]; 00111 float scalefactor; 00112 00115 void update_cov_scale(); 00116 00118 void invalidate_cov_scale(); 00119 00120 public: 00122 DrawMolecule(VMDApp *, Displayable *); 00123 virtual ~DrawMolecule(); 00124 00125 00126 // 00127 // public utility routines 00128 // 00129 wkf_threadpool_t * cpu_threadpool(void); 00130 00132 wkf_threadpool_t * cuda_devpool(void); 00133 00136 int atom_displayed(int); 00137 00138 // 00139 // access routines for the drawn molecule components (which are the children) 00140 // 00141 00143 int components(void) { return int(repList.num()); } 00144 00146 DrawMolItem *component(int); 00147 00149 DrawMolItem *component_from_pickable(const Pickable *); 00150 00153 int get_component_by_name(const char *); 00154 00158 const char *get_component_name(int); 00159 00160 00162 int del_rep(int); 00163 00167 void add_rep(AtomColor *, AtomRep *, AtomSel *, const Material *); 00168 00171 int change_rep(int, AtomColor *, AtomRep *, const char *sel); 00172 00174 int show_rep(int repid, int onoff); 00175 00178 //causing them to be recomputed on the next access. 00179 void force_recalc(int); 00180 00182 void change_pbc(); 00183 00185 void change_ts(); 00186 00189 int highlighted_rep() const; 00190 00191 // 00192 // methods for dealing with frames 00193 // 00194 00196 int numframes() const { return int(timesteps.num()); } 00197 00199 int frame() const { return curframe; } 00200 00202 void override_current_frame(int frame); 00203 00205 Timestep *current() { 00206 if (curframe >= 0 && curframe < timesteps.num()) 00207 return timesteps[curframe]; 00208 return NULL; 00209 } 00210 00212 Timestep *get_frame(int n) { 00213 if ( n>= 0 && n<timesteps.num() ) { 00214 return timesteps[n]; 00215 } 00216 return NULL; 00217 } 00218 00220 Timestep *get_last_frame() { 00221 return get_frame(int(timesteps.num())-1); 00222 } 00223 00225 void delete_frame(int n); 00226 00228 void append_frame(Timestep *); 00229 00232 void duplicate_frame(const Timestep *); 00233 00235 float scale_factor(); 00236 00240 int cov(float &, float &, float &); 00241 00243 int recalc_bonds(void); 00244 00246 int need_secondary_structure(int); 00247 00249 void invalidate_ss(); 00250 00253 int recalc_ss(); 00254 00255 // return pointer to molgraphics so that MoleculeList::check_pickable 00256 // can test for it. 00257 MoleculeGraphics *moleculeGraphics() const { return molgraphics; } 00258 00259 // prepare molecule for redraw 00260 virtual void prepare(); 00261 00263 void register_monitor(DrawMoleculeMonitor *); 00264 00266 void unregister_monitor(DrawMoleculeMonitor *); 00267 00268 void notify(); 00269 }; 00270 00271 #endif 00272