00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef DRAWMOLITEM_H
00026 #define DRAWMOLITEM_H
00027
00028 #include "config.h"
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 VMDSURF
00041 #include "Surf.h"
00042 #endif
00043
00044 #ifdef VMDMSMS
00045 #include "MSMSInterface.h"
00046 #endif
00047
00049 class DrawMolItem : public Displayable {
00050 public:
00051 AtomColor *atomColor;
00052 AtomRep *atomRep;
00053 AtomSel *atomSel;
00054 int repNumber;
00055 char commentBuffer[1024];
00056
00057 char *name;
00058
00059 private:
00060 DrawMolecule *mol;
00061 float *avg;
00062 int avgsize;
00063
00064
00065 char *framesel;
00066
00067
00068 int structwarningcount;
00069
00070 int emitstructwarning(void);
00071
00073
00074 DispCmdColorIndex cmdColorIndex;
00075 DispCmdSphereIndex cmdSphereIndex;
00076 DispCmdSphereArray cmdSphereArray;
00077 DispCmdPointArray cmdPointArray;
00078 DispCmdLine cmdLine;
00079 DispCmdTriangle cmdTriangle;
00080 DispCmdCylinder cmdCylinder;
00081 DispCmdComment cmdCommentX;
00082 DispCmdSphereRes cmdSphres;
00083 DispCmdSphereType cmdSphtype;
00084 DispCmdSquare cmdSquare;
00085 DispCmdLineType cmdLineType;
00086 DispCmdLineWidth cmdLineWidth;
00087 DispCmdTriMesh cmdTriMesh;
00088 DispCmdWireMesh cmdWireMesh;
00089 DispCmdVolSlice cmdVolSlice;
00090 DispCmdPickPoint pickPoint;
00092
00094 struct ColorLookup {
00095 int num;
00096 int max;
00097 int *idlist;
00098 ColorLookup() {
00099 num = 0;
00100 max = 0;
00101 idlist = 0;
00102 }
00103 ~ColorLookup() {
00104 free(idlist);
00105 }
00106 void append(int id) {
00107 if (max == 0) {
00108 idlist = (int *)malloc(8*sizeof(int));
00109 max = 8;
00110 }
00111 if (num == max) {
00112 idlist = (int *)realloc(idlist, 2*num*sizeof(int));
00113 max = 2*num;
00114 }
00115 idlist[num++] = id;
00116 }
00117 };
00118
00120 ColorLookup *colorlookups;
00121 static void update_lookups(AtomColor *, AtomSel *, ColorLookup *);
00122
00124 void update_pbc_transformations();
00125
00126 #ifdef VMDSURF
00127 Surf surf;
00128 #endif
00129
00130 #ifdef VMDMSMS
00131 MSMSInterface msms;
00132 #endif
00133
00134
00135 int voltexVolid;
00136 int voltexColorMethod;
00137 float voltexDataMin, voltexDataMax;
00138
00139
00140 VolumeTexture volumeTexture;
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 typedef ResizeArray<int> TubeIndexList;
00151
00155 ResizeArray<TubeIndexList *> *tubearray;
00156
00158 void generate_tubearray();
00159
00160
00161 void draw_solid_spheres(float *, int res, float radscale, float fixrad);
00162 void draw_residue_beads(float *, int res, float radscale);
00163 void draw_dotted_spheres(float *, float srad, int sres);
00164 void draw_lines(float *, int thickness, float cutoff);
00165 void draw_cpk_licorice(float *, int, float, int, float, int, int, float cutoff);
00166
00167 #ifdef VMDPOLYHEDRA
00168 void draw_polyhedra(float *, float);
00169 #endif
00170 void draw_points(float *, float);
00171 void draw_bonds(float *, float brad, int bres, float cutoff);
00172
00174 void make_connection(float *prev, float *start, float *end, float *next,
00175 float radius, int resolution, int is_cyl);
00176
00178 void draw_spline_curve(int num, float *coords, int *idx,
00179 int use_cyl, float b_rad, int b_res);
00180
00182 void draw_spline_ribbon(int num, float *coords, float *perps,
00183 int *idx, int use_cyl, float b_rad,
00184 int b_res);
00185
00187 void draw_spline_new(int num, const float *coords,
00188 const float *perps, const int *idx,
00189 const float *cpwidths, const float *cpheights,
00190 int numscalefactors, int b_res, int cyclic);
00191
00193 void draw_ribbon_from_points(int numpoints, const float *points,
00194 const float *perps, const int *cols, int numpanels,
00195 const float *heights, const float *widths,
00196 int numscalefactors);
00197
00198 void draw_tube(float *, float radius, int res);
00199 void draw_ribbons(float *, float brad, int bres, float thickness);
00200 void draw_ribbons_new(float *, float, int, int, float);
00201
00202
00203 int draw_protein_ribbons_old(float *, int, float, float, int);
00204 int draw_protein_ribbons_new(float *, int, float, float, int);
00205 int draw_nucleic_ribbons(float *, int, float, float, int, int, int);
00206 int draw_nucleotide_cylinders(float *, int, float, float, int);
00207 int draw_base_sugar_rings(float *, int, float, float, int);
00208 int draw_cartoon_ribbons(float *, int, float, float, int, int);
00210
00211 void draw_structure(float *, float brad, int bres, int linethickness);
00212
00213 void draw_alpha_helix_cylinders(ResizeArray<float> &x,
00214 ResizeArray<float> &y,
00215 ResizeArray<float> &z,
00216 ResizeArray<int> &atom_on, int *color,
00217 float bond_rad, int bond_res,
00218 float *res_start, float *res_end);
00219
00221 void draw_beta_sheet(ResizeArray<float> &x, ResizeArray<float> &y,
00222 ResizeArray<float> &z, ResizeArray<int> &atom_on,
00223 int *color, float ribbon_width,
00224 float *res_start, float *res_end);
00225
00226 void draw_trace(float *pos, float brad, int bres, int linethickness);
00227 void draw_dot_surface(float *pos, float srad, int sres, int method);
00228 void draw_msms(float *pos, int draw_wireframe, int allatoms, float radius, float density);
00229 void draw_surface(float *pos, int draw_wireframe, float radius);
00230 void draw_hbonds(float *, float maxangle, int thickness, float cutoff);
00231 void draw_dynamic_bonds(float *, float brad, int bres, float cutoff);
00232
00233
00234 void draw_volslice(int volid, float slice, int axis, int texmode);
00235
00237 void updateVolumeTexture();
00238
00239 void draw_isosurface(int, float, int, int, int, int);
00240 void draw_volume_field_lines(int volid, float seedval, float minlen, float maxlen, float thickness);
00241
00243
00244 void draw_volume_box_solid(const VolumetricData *);
00245 void draw_volume_box_lines(const VolumetricData *);
00246 void draw_volume_slice(const VolumetricData *, int, float, int);
00247 void draw_volume_texture(const VolumetricData *, int);
00248 void draw_volume_isosurface_points(const VolumetricData *, float, int, int);
00249 void draw_volume_isosurface_lit_points(const VolumetricData *, float, int, int);
00250 void draw_volume_isosurface_trimesh(const VolumetricData *, float, int);
00251 void draw_volume_isosurface_lines(const VolumetricData *, float, int, int);
00252 int draw_volume_get_colorid(void);
00253 void prepare_volume_texture(const VolumetricData *v, int method);
00254 int calcseeds_gradient_magnitude(const VolumetricData *v, ResizeArray<float> *seeds, float seedmin, float seedmax);
00255
00257
00258 #ifdef VMDWITHCARBS
00259
00260
00261 void draw_rings_paperchain(float *framepos, float bipyramid_height, int maxringsize);
00262 void paperchain_get_ring_color(SmallRing &ring, float *framepos, float *rgb);
00263 void paperchain_draw_ring(SmallRing &ring, float *framepos, float bipyramid_height);
00265
00267
00268 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);
00269 void twister_draw_path(LinkagePath &path, float *framepos, int start_end_centroid, int rib_steps, float rib_width, float rib_height);
00270 void twister_draw_ribbon_extensions(ResizeArray<float> &vertices, ResizeArray<float> &colors,
00271 ResizeArray<float> &normals, ResizeArray<int> &facets,
00272 float centroid[3], float normal[3], float right[3], float rib_point[3],
00273 float rib_height, float rib_width,
00274 float top_color[3], float bottom_color[3]);
00275 void twister_draw_hexagon(ResizeArray<float> &vertices, ResizeArray<float> &colors, ResizeArray<float> &normals,
00276 ResizeArray<int> &facets, float centroid[3], float normal[3],
00277 float first_atom[3], float rib_height, float rib_width,
00278 float top_color[3], float bottom_color[3]);
00280
00282
00283 void get_ring_centroid_and_normal(float *centroid, float *normal, SmallRing &ring, float *framepos);
00284 bool smallring_selected(SmallRing &ring);
00285 bool linkagepath_selected(LinkagePath &path);
00287 #endif
00288
00289 void create_cmdlist(void);
00290 void do_create_cmdlist();
00291
00292 public:
00300 enum RegenChoices {NO_REGEN = 0, MOL_REGEN = 1, SEL_REGEN = 2,
00301 REP_REGEN = 4, COL_REGEN = 8};
00302
00303 private:
00304 int needRegenerate;
00305 int update_pbc;
00306 int update_ss;
00307 int update_ts;
00308 int update_traj;
00309 void place_picks(void);
00310
00311 protected:
00312 virtual void do_color_changed(int);
00313 virtual void do_color_rgb_changed(int);
00314 virtual void do_color_scale_changed();
00315
00316 public:
00317
00318 DrawMolItem(const char *, DrawMolecule *, AtomColor *, AtomRep *, AtomSel *);
00319 virtual ~DrawMolItem(void);
00320
00321 int change_color(AtomColor *);
00322 int change_rep(AtomRep *);
00323 int change_sel(const char *);
00324 void force_recalc(int);
00325 int atom_displayed(int);
00326 int representation_index(void);
00327
00328 int set_smoothing(int n) {
00329 if (n >= 0) {
00330 avgsize = n;
00331 return TRUE;
00332 }
00333 return FALSE;
00334 }
00335 int get_smoothing() const {
00336 return avgsize;
00337 }
00338
00342 void set_drawframes(const char *frames);
00343 const char *get_drawframes() const { return framesel; }
00344
00347 void set_pbc(int);
00348 int get_pbc() const;
00349
00351 void set_pbc_images(int);
00352 int get_pbc_images() const;
00353
00356 void change_pbc() { update_pbc = 1; }
00357
00359 void change_ss() { update_ss = 1; }
00360
00362 void change_ts() { update_ts = 1; }
00363
00365 void change_traj() { update_traj = 1; }
00366
00367
00368
00369
00370 virtual void prepare();
00371
00374 virtual int pickable_on();
00375
00377
00378 virtual void pick_start(PickMode *p, DisplayDevice *d,
00379 int btn, int tag, const int *cell, int dim,
00380 const float *pos) {
00381 p->pick_molecule_start(mol, d, btn, tag, cell, dim, pos);
00382 }
00383
00384 virtual void pick_move(PickMode *p, DisplayDevice *d,
00385 int tag, int dim, const float *pos) {
00386 p->pick_molecule_move (mol, d, tag, dim, pos);
00387 }
00388
00389 virtual void pick_end(PickMode *p, DisplayDevice *d) {
00390 p->pick_molecule_end (mol, d);
00391 }
00393
00394 protected:
00395 float spline_basis[4][4];
00396 };
00397
00398 #endif
00399