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

DrawMolItem.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: DrawMolItem.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.185 $      $Date: 2019/09/26 03:40:14 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * Child Displayable component of a molecule; this is responsible for doing
00020  * the actual drawing of a molecule.  It contains an atom color, atom
00021  * selection, and atom representation object to specify how this component
00022  * should look.
00023  *
00024  ***************************************************************************/
00025 #ifndef DRAWMOLITEM_H
00026 #define DRAWMOLITEM_H
00027 
00028 #include "config.h"         // to force recompilation on config changes
00029 #include "Displayable.h"
00030 #include "DispCmds.h"
00031 #include "AtomColor.h"
00032 #include "AtomRep.h"
00033 #include "AtomSel.h"
00034 #include "PickMode.h"
00035 #include "BaseMolecule.h"
00036 #include "VolumeTexture.h"
00037 
00038 class DrawMolecule;         
00039 
00040 #ifdef VMDMSMS
00041 #include "MSMSInterface.h"
00042 #endif
00043 
00044 #ifdef VMDNANOSHAPER
00045 #include "NanoShaperInterface.h"
00046 #endif
00047 
00048 #ifdef VMDSURF
00049 #include "Surf.h"
00050 #endif
00051 
00052 #include "QuickSurf.h"
00053 
00055 class DrawMolItem : public Displayable {
00056 public:
00057   AtomColor *atomColor;     
00058   AtomRep *atomRep;         
00059   AtomSel *atomSel;         
00060   int repNumber;            
00061   char commentBuffer[1024]; 
00062 
00063   char *name;               
00064 
00065 private:
00066   DrawMolecule *mol;        
00067   float *avg;               
00068   int avgsize;              
00069 
00070  
00071   char *framesel;           
00072 
00073 
00074   int structwarningcount;   
00075 
00076   int emitstructwarning(void); 
00077 
00079 
00080   DispCmdBeginRepGeomGroup cmdBeginRepGeomGroup;
00081   DispCmdColorIndex        cmdColorIndex;
00082   DispCmdComment           cmdCommentX;
00083   DispCmdCylinder          cmdCylinder;
00084   DispCmdLatticeCubeArray  cmdCubeArray;
00085   DispCmdLine              cmdLine;
00086   DispCmdLineType          cmdLineType;
00087   DispCmdLineWidth         cmdLineWidth;
00088   DispCmdPointArray        cmdPointArray;
00089   DispCmdSphere            cmdSphere;
00090   DispCmdSphereRes         cmdSphres;
00091   DispCmdSphereType        cmdSphtype;
00092   DispCmdSphereArray       cmdSphereArray;
00093   DispCmdSquare            cmdSquare;
00094   DispCmdTriangle          cmdTriangle;
00095   DispCmdTriMesh           cmdTriMesh;
00096   DispCmdVolSlice          cmdVolSlice;
00097   DispCmdWireMesh          cmdWireMesh;
00099 
00101   struct ColorLookup {
00102     int num;
00103     int max;
00104     int *idlist;
00105     ColorLookup() {
00106       num = 0;
00107       max = 0;
00108       idlist = 0;
00109     }
00110     ~ColorLookup() {
00111       free(idlist);
00112     }
00113     void append(int id) {
00114       if (max == 0) {
00115         idlist = (int *)malloc(8L*sizeof(int)); 
00116         max = 8;
00117       }
00118       if (num == max) {
00119         idlist = (int *)realloc(idlist, 2L*num*sizeof(int));
00120         max = 2L*num;
00121       }
00122       idlist[num++] = id;
00123     }
00124   };
00125  
00127   ColorLookup *colorlookups;      
00128   static void update_lookups(AtomColor *, AtomSel *, ColorLookup *);
00129 
00131   void update_pbc_transformations();
00132 
00134   void update_instance_transformations();
00135 
00136 #ifdef VMDMSMS
00137   MSMSInterface msms;          
00138 #endif
00139 
00140 #ifdef VMDNANOSHAPER
00141   NanoShaperInterface nanoshaper; 
00142 #endif
00143 
00144 #ifdef VMDSURF
00145   Surf surf;                   
00146 #endif
00147 
00148   int waveftype;               
00149   int wavefspin;               
00150   int wavefexcitation;         
00151   int gridorbid;               
00152   float orbgridspacing;        
00153   int orbgridisdensity;        
00154   VolumetricData *orbvol;      
00155 
00156   // cached volume texture information to avoid unnecessary updates
00157   int voltexVolid;
00158   int voltexColorMethod;
00159   float voltexDataMin, voltexDataMax;
00160 
00161   // encapsulate data for color by volume used by this rep
00162   VolumeTexture volumeTexture;
00163 
00164   // Auxiliary data structure for rendering tubes.
00165   // Since the control points are based on fixed atom indices, we can
00166   // find all those indices once, cache them, then just look up the
00167   // coordinates when it's time to draw a frame.  Should speed up
00168   // animation, as well as perhaps make it easier to add better-looking
00169   // tube reps later.
00170  
00171   // TubeIndexList holds a set of control point indices.
00172   typedef ResizeArray<int> TubeIndexList;
00173 
00177   ResizeArray<TubeIndexList *> *tubearray;
00178 
00180   void generate_tubearray();
00181 
00182   // commands to draw different representations for a given selection 
00183   void draw_solid_cubes(float *, float radscale);
00184   void draw_solid_spheres(float *, int res, float radscale, float fixrad);
00185   void draw_residue_beads(float *, int res, float radscale);
00186   void draw_dotted_spheres(float *, float srad, int sres); 
00187   void draw_lines(float *, int thickness, float cutoff);   
00188   void draw_cpk_licorice(float *, int, float, int, float, int, int, float cutoff); 
00189 
00190 #ifdef VMDPOLYHEDRA
00191   void draw_polyhedra(float *, float); 
00192 #endif
00193   void draw_points(float *, float);                   
00194   void draw_bonds(float *, float brad, int bres, float cutoff);             
00195 
00197   void make_connection(float *prev, float *start, float *end, float *next,
00198                        float radius, int resolution, int is_cyl);
00199 
00201   void draw_spline_curve(int num, float *coords, int *idx,
00202                          int use_cyl, float b_rad, int b_res);
00203 
00205   void draw_spline_ribbon(int num, float *coords, float *perps,
00206                           int *idx, int use_cyl, float b_rad,
00207                           int b_res);
00208 
00210   void draw_spline_new(int num, const float *coords, 
00211                        const float *perps, const int *idx, 
00212                        const float *cpwidths, const float *cpheights, 
00213                        int numscalefactors, int b_res, int cyclic);
00214 
00216   void draw_ribbon_from_points(int numpoints, const float *points, 
00217                   const float *perps, const int *cols, int numpanels,
00218                   const float *heights, const float *widths, 
00219                   int numscalefactors);
00220 
00221   void draw_tube(float *, float radius, int res);   
00222   void draw_ribbons(float *, float brad, int bres, float thickness); 
00223   void draw_ribbons_new(float *, float, int, int, float);  
00224 
00225 
00226   int draw_protein_ribbons_old(float *, int, float, float, int);
00227   int draw_protein_ribbons_new(float *, int, float, float, int);
00228   int draw_nucleic_ribbons(float *, int, float, float, int, int, int);
00229   int draw_nucleotide_cylinders(float *, int, float, float, int);
00230   int draw_base_sugar_rings(float *, int, float, float, int);
00231   int draw_cartoon_ribbons(float *, int, float, float, int, int);
00233 
00234   void draw_structure(float *, float brad, int bres, int linethickness); 
00235 
00236   void draw_alpha_helix_cylinders(ResizeArray<float> &x,
00237                                   ResizeArray<float> &y,
00238                                   ResizeArray<float> &z,
00239                                   ResizeArray<int> &atom_on, int *color,
00240                                   float bond_rad, int bond_res,
00241                                   float *res_start, float *res_end);
00242 
00244   void draw_beta_sheet(ResizeArray<float> &x, ResizeArray<float> &y,
00245                        ResizeArray<float> &z, ResizeArray<int> &atom_on, 
00246                        int *color, float ribbon_width,
00247                        float *res_start, float *res_end);
00248 
00249   void draw_trace(float *pos, float brad, int bres, int linethickness); 
00250   void draw_dot_surface(float *pos, float srad, int sres, int method); 
00251   void draw_msms(float *pos, int draw_wireframe, int allatoms, float radius, float density); 
00252   void draw_nanoshaper(float *pos, int surftype, int draw_wireframe, float gspacing, float probe_rad, float skin_parm, float blob_parm); 
00253   void draw_quicksurf(float *pos, int quality, float radius, float isovalue, float spacing); 
00254   void draw_surface(float *pos, int draw_wireframe, float radius); 
00255   void draw_hbonds(float *, float maxangle, int thickness, float cutoff); 
00256   void draw_dynamic_bonds(float *, float brad, int bres, float cutoff); 
00257 
00258   // Drawing functions for volumetric and isosurface data 
00259   void draw_volslice(int volid, float slice, int axis, int texmode); 
00260 
00262   void updateVolumeTexture();
00263 
00264   void draw_isosurface(int, float, int, int, int, int); 
00265   void draw_volume_field_lines(int volid, int seedusegrid, int maxseeds, float seedval, float deltacell, float minlen, float maxlen, int drawtubes, int tuberes, float thickness); 
00266 
00267   void draw_orbital(int, int, int, int, int, float, int, int, float, int, int); 
00268 
00270   // helper functions for volume rendering
00271   void draw_volume_box_solid(VolumetricData *);
00272   void draw_volume_box_lines(VolumetricData *);
00273   void draw_volume_slice(const VolumetricData *, int, float, int);
00274   void draw_volume_texture(const VolumetricData *, int);
00275   void draw_volume_isosurface_points(const VolumetricData *, float, int, int);
00276   void draw_volume_isosurface_lit_points(VolumetricData *, float, int, int);
00277   void draw_volume_isosurface_trimesh(VolumetricData *, float, int, const float *voltex=NULL);
00278   void draw_volume_isosurface_lines(VolumetricData *, float, int, int);
00279   int  draw_volume_get_colorid(void);
00280   void prepare_volume_texture(const VolumetricData *v, int method);
00281   int calcseeds_grid(VolumetricData *v, ResizeArray<float> *seeds, int maxseedcount);
00282   int calcseeds_gradient_magnitude(VolumetricData *v, ResizeArray<float> *seeds, float seedmin, float seedmax, int maxseedcount);
00283 
00285 
00286 #ifdef VMDWITHCARBS
00287 
00288   // functions for rendering small rings using the PaperChain algorithm
00289   void draw_rings_paperchain(float *framepos, float bipyramid_height, int maxringsize);
00290   void paperchain_get_ring_color(SmallRing &ring, float *framepos, float *rgb);
00291   void paperchain_draw_ring(SmallRing &ring, float *framepos, float bipyramid_height);
00293   
00295   // functions for rendering small rings using the Twister algorithm
00296   void draw_rings_twister(float *framepos, int start_end_centroid, int hide_shared_links, int rib_steps, float rib_width, float rib_height, int maxringsize, int maxpathlength);
00297   void twister_draw_path(LinkagePath &path, float *framepos, int start_end_centroid, int rib_steps, float rib_width, float rib_height);
00298   void twister_draw_ribbon_extensions(ResizeArray<float> &vertices, ResizeArray<float> &colors,
00299                                       ResizeArray<float> &normals, ResizeArray<int> &facets,
00300                                       float centroid[3], float normal[3], float right[3], float rib_point[3],
00301                                       float rib_height, float rib_width,
00302                                       float top_color[3], float bottom_color[3]);
00303   void twister_draw_hexagon(ResizeArray<float> &vertices, ResizeArray<float> &colors, ResizeArray<float> &normals,
00304                                       ResizeArray<int> &facets, float centroid[3], float normal[3],
00305                                       float first_atom[3], float rib_height, float rib_width,
00306                                       float top_color[3], float bottom_color[3]);
00308   
00310   // utility functions for Twister and Paper Chain
00311   void get_ring_centroid_and_normal(float *centroid, float *normal, SmallRing &ring, float *framepos);
00312   bool smallring_selected(SmallRing &ring);
00313   bool linkagepath_selected(LinkagePath &path);
00315 #endif
00316 
00317   void create_cmdlist(void);            
00318   void do_create_cmdlist();             
00319 
00320 public:
00328   enum RegenChoices {NO_REGEN = 0, MOL_REGEN = 1, SEL_REGEN = 2,
00329                      REP_REGEN = 4, COL_REGEN = 8};
00330 
00331 private:
00332   int needRegenerate;                   
00333   int update_pbc;                       
00334   int update_instances;                 
00335   int update_ss;                        
00336   int update_ts;                        
00337   int update_traj;                      
00338   void place_picks(float *pos);         
00339 
00340 protected:
00341   virtual void do_color_changed(int);
00342   virtual void do_color_rgb_changed(int);
00343   virtual void do_color_scale_changed();
00344 
00345 public:
00346   // constructor: name, parent molecule, and atom drawing methods
00347   DrawMolItem(const char *, DrawMolecule *, AtomColor *, AtomRep *, AtomSel *);
00348   virtual ~DrawMolItem(void);
00349   
00350   int change_color(AtomColor *);        
00351   int change_rep(AtomRep *);            
00352   int change_sel(const char *);         
00353   void force_recalc(int);               
00354   int atom_displayed(int);              
00355   int representation_index(void);       
00356 
00357   int set_smoothing(int n) {           
00358     if (n >= 0) {
00359       avgsize = n; 
00360       return TRUE;
00361     }
00362     return FALSE;
00363   }
00364   int get_smoothing() const {           
00365     return avgsize;
00366   }
00367 
00371   void set_drawframes(const char *frames);
00372   const char *get_drawframes() const { return framesel; }
00373    
00376   void set_pbc(int);
00377   int get_pbc() const;
00378 
00380   void set_pbc_images(int);
00381   int get_pbc_images() const;
00382 
00385   void change_pbc() { update_pbc = 1; }
00386 
00387 
00390   void set_instances(int);
00391   int get_instances() const;
00392 
00395   void change_instances() { update_instances = 1; }
00396 
00397 
00399   void change_ss() { update_ss = 1; }
00400 
00402   void change_ts() { update_ts = 1; }
00403 
00405   void change_traj() { update_traj = 1; }
00406 
00407   //
00408   // public virtual routines
00409   //
00410   virtual void prepare();               
00411 
00414   virtual int pickable_on();
00415 
00417 
00418   virtual void pick_start(PickMode *p, DisplayDevice *d,
00419                           int btn, int tag, const int *cell, int dim, 
00420                           const float *pos) {
00421     p->pick_molecule_start(mol, d, btn, tag, cell, dim, pos);
00422   }
00423 
00424   virtual void pick_move(PickMode *p, DisplayDevice *d,
00425                           int tag, int dim, const float *pos) {
00426     p->pick_molecule_move (mol, d, tag, dim, pos);
00427   }
00428 
00429   virtual void pick_end(PickMode *p, DisplayDevice *d) {
00430     p->pick_molecule_end  (mol, d);
00431   }
00433 
00434 protected:
00435   float spline_basis[4][4];          
00436 };
00437 
00438 #endif
00439 

Generated on Tue Apr 16 02:45:14 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002