00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VMD_APP_H
00021 #define VMD_APP_H
00022
00023 #include "PluginMgr.h"
00024 class AtomSel;
00025 class Plugin;
00026 class CUDAAccel;
00027 class NVENCMgr;
00028 class DisplayDevice;
00029 class SymbolTable;
00030 class Scene;
00031 class PickList;
00032 class PickModeList;
00033 class Axes;
00034 class DisplayRocker;
00035 class CommandQueue;
00036 class UIText;
00037 class MoleculeList;
00038 class GeometryList;
00039 class IMDMgr;
00040 class Stage;
00041 class Mouse;
00042 class FPS;
00043 class Matrix4;
00044 class Animation;
00045 class Mobile;
00046 class Spaceball;
00047 #ifdef WIN32
00048 class Win32Joystick;
00049 #endif
00050 class UIVR;
00051 class FileRenderList;
00052 class VMDTitle;
00053 class MaterialList;
00054 class VideoStream;
00055 class VMDMenu;
00056 class VMDCollab;
00057 class QuickSurf;
00058
00059
00060 struct wkf_cpu_caps_struct;
00061 typedef wkf_cpu_caps_struct wkf_cpu_caps_t;
00062 struct wkf_threadpool_struct;
00063 typedef wkf_threadpool_struct wkf_threadpool_t;
00064
00065 #include <string.h>
00066 #include "NameList.h"
00067 #include "JString.h"
00068 #include "vmdplugin.h"
00069 #include "ProfileHooks.h"
00070
00071 #define VMD_CHECK_EVENTS 1
00072 #define VMD_IGNORE_EVENTS 0
00073
00075 struct FileSpec {
00076 enum WaitFor { WAIT_ALL=-1,
00077 WAIT_BACK=1
00078 };
00079
00080 int autobonds;
00081 int filebonds;
00082 int first;
00083 int last;
00084 int stride;
00085 int waitfor;
00086 int nvolsets;
00087 int *setids;
00088 int *selection;
00089
00090 FileSpec() {
00091 autobonds = 1;
00092 filebonds = 1;
00093 first = 0;
00094 last = -1;
00095 stride = 1;
00096 waitfor = WAIT_BACK;
00097 nvolsets = -1;
00098 setids = NULL;
00099 selection = NULL;
00100 }
00101
00102 FileSpec(const FileSpec &s) {
00103 autobonds=s.autobonds;
00104 filebonds=s.filebonds;
00105 first=s.first;
00106 last=s.last;
00107 stride=s.stride;
00108 waitfor=s.waitfor;
00109 nvolsets=s.nvolsets;
00110 if (nvolsets > 0) {
00111 setids = new int[nvolsets];
00112 memcpy(setids, s.setids, nvolsets*sizeof(int));
00113 } else {
00114 setids = NULL;
00115 }
00116
00117
00118
00119 selection = NULL;
00120 }
00121
00122 ~FileSpec() {
00123 if (setids)
00124 delete [] setids;
00125 }
00126 };
00127
00128
00130 class VMDApp {
00131 public:
00133 VMDApp(int argc, char **argv, int mpion);
00134
00141 int VMDinit(int, char **, const char *, int * dispLoc, int * dispSize);
00142
00143 ~VMDApp();
00144
00147 void VMDexit(const char *exitmsg, int exitcode, int pauseseconds);
00148
00149 private:
00154 int mpienabled;
00155
00156 #if defined(VMDXPLOR)
00157
00158 static VMDApp* obj;
00159 #endif
00160
00162 static JString text_message;
00163
00165 NameList<VMDMenu *> *menulist;
00166
00168 int nextMolID;
00169
00171 int stride_firsttime;
00172
00174 int eofexit;
00175
00177 int backgroundprocessing;
00178
00179 Mouse *mouse;
00180 DisplayRocker *rocker;
00181
00183 Mobile *mobile;
00184
00186 Spaceball *spaceball;
00187
00188 #ifdef WIN32
00189
00190 Win32Joystick *win32joystick;
00191 #endif
00192
00193 VMDTitle *vmdTitle;
00194 FileRenderList *fileRenderList;
00195 PluginMgr *pluginMgr;
00196
00197 public:
00198 int argc_m;
00199 const char **argv_m;
00200
00201
00202 UIText *uiText;
00203 UIVR *uivr;
00204 IMDMgr *imdMgr;
00205 VideoStream *uivs;
00206 Animation *anim;
00207 DisplayDevice *display;
00208 Scene *scene;
00209
00210 wkf_cpu_caps_t *cpucaps;
00211
00212 wkf_threadpool_t *thrpool;
00213
00214 CUDAAccel *cuda;
00215
00216 NVENCMgr *nvenc;
00217
00218 QuickSurf *qsurf;
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 PickList *pickList;
00230 PickModeList *pickModeList;
00231 MaterialList *materialList;
00232 Stage *stage;
00233 Axes *axes;
00234 FPS *fps;
00235 CommandQueue *commandQueue;
00236 MoleculeList *moleculeList;
00237 GeometryList *geometryList;
00238 SymbolTable *atomSelParser;
00239 VMDCollab *vmdcollab;
00240 NameList<char *> userKeys;
00241 NameList<char *> userKeyDesc;
00242 int UpdateDisplay;
00243 int exitFlag;
00244 int ResetViewPending;
00245 char nodename[512];
00246 int noderank;
00247 int nodecount;
00248
00251 int highlighted_molid, highlighted_rep;
00252
00253
00254
00255
00256
00262 int background_processing() { return backgroundprocessing; }
00263 void background_processing_clear() { backgroundprocessing = 0; }
00264 void background_processing_set() { backgroundprocessing = 1; }
00265
00270 void deactivate_uitext_stdin();
00271
00272
00273
00274
00275
00278 int activate_menus();
00279
00280 int num_menus();
00281 const char *menu_name(int);
00282 int menu_id(const char *name);
00283 int add_menu(VMDMenu *);
00284 int remove_menu(const char *);
00285
00288 void menu_add_extension(const char *shortname, const char *menu_path);
00289 void menu_remove_extension(const char *shortname);
00290
00293 int menu_status(const char *name);
00294
00296 int menu_location(const char *name, int &x, int &y);
00297
00299 int menu_show(const char *name, int on);
00300
00302 int menu_move(const char *name, int x, int y);
00303
00305 int menu_select_mol(const char *name, int molno);
00306
00307
00308
00309
00310
00311 int filerender_num();
00312 const char *filerender_name(int n);
00313 const char *filerender_prettyname(int n);
00314 int filerender_valid(const char *method);
00315
00317 const char *filerender_shortname_from_prettyname(const char *pretty);
00318
00320 int filerender_has_antialiasing(const char *method);
00321
00323 int filerender_aasamples(const char *method, int aasamples);
00324
00326 int filerender_aosamples(const char *method, int aosamples);
00327
00329 int filerender_has_imagesize(const char *method);
00330
00335 int filerender_imagesize(const char *method, int *imgwidth, int *imgheight);
00336
00342 int filerender_aspectratio(const char *method, float *aspect);
00343
00346 int filerender_numformats(const char *method);
00347
00349 const char *filerender_get_format(const char *method, int i);
00350
00352 const char *filerender_cur_format(const char *method);
00353
00355 int filerender_set_format(const char *method, const char *format);
00356
00358 int filerender_render(const char *method, const char *filename,
00359 const char *extcmd);
00360
00364 const char *filerender_option(const char *method, const char *option);
00365
00367 const char *filerender_default_option(const char *method);
00368
00370 const char *filerender_default_filename(const char *method);
00371
00372
00373
00374
00375
00380 int scene_rotate_by(float angle, char axis, float incr = 0);
00381 int scene_rotate_to(float angle, char axis);
00382
00385 int scene_rotate_by(const float *);
00386 int scene_rotate_to(const float *);
00387
00389 int scene_translate_by(float x, float y, float z);
00390 int scene_translate_to(float x, float y, float z);
00391
00393 int scene_scale_by(float s);
00394 int scene_scale_to(float s);
00395
00398 void scene_resetview_newmoldata();
00399
00402 void scene_resetview();
00403
00407 int scene_rock(char axis, float step, int nsteps = 0);
00408
00410 int scene_rockoff();
00411
00414 int scene_stoprotation();
00415
00429 int animation_num_dirs();
00430 const char *animation_dir_name(int);
00431
00433 int animation_set_dir(int);
00434
00436 int animation_num_styles();
00437 const char *animation_style_name(int);
00438
00440 int animation_set_style(int);
00441
00446 int animation_set_frame(int frame);
00447
00449 int animation_set_stride(int);
00450
00454 int animation_set_speed(float);
00455
00456
00457
00458
00459
00460
00464 vmdplugin_t *get_plugin(const char *type, const char *name);
00465
00469 int list_plugins(PluginList &, const char *type = NULL);
00470
00473 int plugin_dlopen(const char *filename);
00474
00478 void plugin_update();
00479
00480
00481
00482
00483
00485 void display_update_on(int);
00486
00488 int display_update_status();
00489
00491 void display_update();
00492
00494 void display_update_ui();
00495
00496
00497
00498
00499
00500
00501
00503 void display_set_screen_height(float);
00504 float display_get_screen_height();
00505
00507 void display_set_screen_distance(float);
00508 float display_get_screen_distance();
00509
00511 void display_set_position(int x, int y);
00512
00513
00515 void display_set_size(int w, int h);
00516 void display_get_size(int *w, int *h);
00517
00519 int display_set_stereo(const char *mode);
00520
00522 int display_set_stereo_swap(int onoff);
00523
00525 int display_set_cachemode(const char *mode);
00526
00528 int display_set_rendermode(const char *mode);
00529
00531 int display_set_eyesep(float sep);
00532
00534 int display_set_focallen(float flen);
00535
00537 int display_set_projection(const char *proj);
00538
00540 int display_projection_is_perspective(void);
00541
00542 int display_set_aa(int onoff);
00543 int display_set_depthcue(int onoff);
00544 int display_set_culling(int onoff);
00545 int display_set_fps(int onoff);
00546 int display_set_background_mode(int mode);
00547
00548
00549 int display_set_nearclip(float amt, int isdelta);
00550 int display_set_farclip(float amt, int isdelta);
00551
00552 int stage_set_location(const char *);
00553 int stage_set_numpanels(int);
00554 int stage_set_size(float);
00555
00556 int axes_set_location(const char *);
00557
00558 int light_on(int lightnum, int onoff);
00559 int light_highlight(int lightnum, int onoff);
00560 int light_rotate(int lightnum, float amt, char axis);
00561 int light_move(int lightnum, const float *newpos);
00562
00563
00564
00565 int depthcue_set_mode(const char *);
00566 int depthcue_set_start(float);
00567 int depthcue_set_end(float);
00568 int depthcue_set_density(float);
00569
00570 int display_set_shadows(int onoff);
00571
00572 int display_set_ao(int onoff);
00573 int display_set_ao_ambient(float a);
00574 int display_set_ao_direct(float d);
00575
00576 int display_set_dof(int onoff);
00577 int display_set_dof_fnumber(float f);
00578 int display_set_dof_focal_dist(float d);
00579
00580
00583
00584
00585
00586
00587
00588
00589
00590
00591
00593 int num_color_categories();
00594
00596 const char *color_category(int);
00597
00601 int color_add_item(const char *cat, const char *item, const char *defcolor);
00602
00604 int num_color_category_items(const char *category);
00605
00607 const char *color_category_item(const char *category, int);
00608
00610 int num_colors();
00611
00613 int num_regular_colors();
00614
00617 const char *color_name(int n);
00618
00623 int color_index(const char *);
00624
00626 int color_value(const char *colorname, float *r, float *g, float *b);
00627
00631 int color_default_value(const char *colorname, float *r, float *g, float *b);
00632
00634 const char *color_mapping(const char *category, const char *item);
00635
00638 const char *color_get_restype(const char *resname);
00639
00644 int color_set_restype(const char *resname, const char *newtype);
00645
00646
00648 int colorscale_params(float *midpoint, float *min, float *max,
00649 int *rev, int *posterize);
00650
00652 int colorscale_setparams(float midpoint, float min, float max,
00653 int rev, int posterize);
00654
00656 int num_colorscale_methods();
00657 int colorscale_method_current();
00658 const char *colorscale_method_name(int);
00659 const char *colorscale_method_menuname(int);
00660
00662 int colorscale_setmethod(int method);
00663
00665 int colorscale_method_index(const char *);
00666
00668 int get_colorscale_colors(int whichScale,
00669 float min[3], float mid[3], float max[3]);
00671 int set_colorscale_colors(int whichScale,
00672 const float min[3], const float mid[3], const float max[3]);
00673
00674
00677 int color_change_name(const char *category, const char *colorname,
00678 const char *color);
00679
00682 int color_change_namelist(int numcols, char **category,
00683 char **colorname, char **color);
00684
00686 int color_get_from_name(const char *category, const char *colorname,
00687 const char **color);
00688
00690 int color_change_rgb(const char *color, float r, float g, float b);
00691
00693 int color_change_rgblist(int numcols, const char **colors, float *rgb3fv);
00694
00695
00696
00697
00698
00699
00701 int logfile_read(const char *path);
00702
00705 int save_state();
00706
00709 int textinterp_change(const char *interpname);
00710
00711
00712
00713
00714
00716 int num_molecules();
00717
00722 int molecule_new(const char *name, int natoms, int docallbacks=1);
00723
00726 int molecule_from_selection_list(const char *name, int mergemode,
00727 int numsels, AtomSel **, int docallbacks=1);
00728
00731 const char *guess_filetype(const char *filename);
00732
00740 int molecule_load(int molid, const char *filename, const char *filetype,
00741 const FileSpec *spec);
00742
00745 int molecule_add_volumetric(int molid, const char *dataname,
00746 const float origin[3], const float xaxis[3], const float yaxis[3],
00747 const float zaxis[3], int xsize, int ysize, int zsize, float *datablock);
00748
00749 int molecule_add_volumetric(int molid, const char *dataname,
00750 const double origin[3], const double xaxis[3], const double yaxis[3],
00751 const double zaxis[3], int xsize, int ysize, int zsize, float *datablock);
00752
00759 int molecule_savetrajectory(int molid, const char *filename,
00760 const char *filetype, const FileSpec *spec);
00761
00764 int molecule_deleteframes(int molid, int first, int last, int stride);
00765
00769 int molecule_index_from_id(int molid);
00770
00774 int molecule_id(int);
00775
00777 int molecule_valid_id(int molid);
00778
00781 int molecule_numatoms(int molid);
00782
00785 int molecule_numframes(int molid);
00786
00789 int molecule_frame(int molid);
00790
00793 int molecule_dupframe(int molid, int frame);
00794
00796 const char *molecule_name(int molid);
00797 int molecule_rename(int molid, const char *newname);
00798
00800 int molecule_cancel_io(int molid);
00801
00803 int molecule_delete(int molid);
00804
00806 int molecule_delete_all(void);
00807
00810 int molecule_activate(int molid, int onoff);
00811 int molecule_is_active(int molid);
00812
00815 int molecule_fix(int molid, int onoff);
00816 int molecule_is_fixed(int molid);
00817
00820 int molecule_display(int molid, int onoff);
00821 int molecule_is_displayed(int molid);
00822
00825 int molecule_make_top(int molid);
00826
00828 int molecule_top();
00829
00831 int num_molreps(int molid);
00832
00833
00834
00835
00836
00837
00839 const char *molrep_get_style(int molid, int repid);
00840 int molrep_set_style(int molid, int repid, const char *style);
00841
00843 const char *molrep_get_color(int molid, int repid);
00844 int molrep_set_color(int molid, int repid, const char *color);
00845
00847 const char *molrep_get_selection(int molid, int repid);
00848 int molrep_set_selection(int molid, int repid, const char *selection);
00849
00852 int molrep_numselected(int molid, int repid);
00853
00855 const char *molrep_get_material(int molid, int repid);
00856 int molrep_set_material(int molid, int repid, const char *material);
00857
00860 int num_clipplanes();
00861
00864 int molrep_get_clipplane(int molid, int repid, int clipid, float *center,
00865 float *normal, float *color, int *mode);
00867 int molrep_set_clipcenter(int molid, int repid, int clipid,
00868 const float *center);
00869 int molrep_set_clipnormal(int molid, int repid, int clipid,
00870 const float *normal);
00871 int molrep_set_clipcolor(int molid, int repid, int clipid,
00872 const float *color);
00873 int molrep_set_clipstatus(int molid, int repid, int clipid, int onoff);
00874
00878 int molrep_set_smoothing(int molid, int repid, int n);
00879
00882 int molrep_get_smoothing(int molid, int repid);
00883
00884
00885
00886
00887
00889 const char *molrep_get_name(int molid, int repid);
00890
00893 int molrep_get_by_name(int molid, const char *);
00894
00896 int molrep_set_pbc(int molid, int repid, int pbc);
00897
00899 int molrep_get_pbc(int molid, int repid);
00900
00902 int molrep_set_pbc_images(int molid, int repid, int n);
00903
00905 int molrep_get_pbc_images(int molid, int repid);
00906
00907
00909 int molecule_add_instance(int molid, Matrix4 &inst);
00910
00912 int molecule_num_instances(int molid);
00913
00915 int molecule_delete_all_instances(int molid);
00916
00918 int molrep_set_instances(int molid, int repid, int inst);
00919
00921 int molrep_get_instances(int molid, int repid);
00922
00923
00926 int molrep_show(int molid, int repid, int onff);
00927
00929 int molrep_is_shown(int molid, int repid);
00930
00931
00932
00933
00934
00935
00936
00937 const char *molecule_get_style();
00938 int molecule_set_style(const char *style);
00939
00940 const char *molecule_get_color();
00941 int molecule_set_color(const char *color);
00942
00943 const char *molecule_get_selection();
00944 int molecule_set_selection(const char *selection);
00945
00946 const char *molecule_get_material();
00947 int molecule_set_material(const char *material);
00948
00951 int molecule_addrep(int molid);
00952
00954 int molecule_modrep(int molid, int repid);
00955
00957 int molrep_delete(int molid, int repid);
00958
00960
00961
00962
00963 int molrep_get_selupdate(int molid, int repid);
00964 int molrep_set_selupdate(int molid, int repid, int onoff);
00966
00968
00969 int molrep_get_colorupdate(int molid, int repid);
00970 int molrep_set_colorupdate(int molid, int repid, int onoff);
00972
00974
00975 int molrep_get_scaleminmax(int molid, int repid, float *min, float *max);
00976 int molrep_set_scaleminmax(int molid, int repid, float min, float max);
00977 int molrep_reset_scaleminmax(int molid, int repid);
00979
00983 int molrep_set_drawframes(int molid, int repid, const char *framesel);
00984 const char *molrep_get_drawframes(int molid, int repid);
00985
00988 int molecule_set_dataset_flag(int molid, const char *dataflagstr, int setval);
00989
00994 int molecule_reanalyze(int molid);
00995
00998 int molecule_bondsrecalc(int molid);
00999
01003 int molecule_ssrecalc(int molid);
01004
01007 int molecule_orblocalize(int molid, int waveid);
01008
01009
01010
01011
01012
01015 int imd_connect(int molid, const char *host, int port);
01016
01018 int imd_connected(int molid);
01019
01022 int imd_sendforces(int, const int *, const float *);
01023
01025 int imd_disconnect(int molid);
01026
01027
01028
01029
01030
01031
01032
01035 int vs_connect(const char *host, int port);
01036
01038 int vs_connected();
01039
01041 int vs_disconnect();
01042
01043
01044
01045
01046
01047
01048
01050 const char * par_name() { return nodename; }
01051
01053 int par_rank() { return noderank; }
01054
01056 int par_size() { return nodecount; }
01057
01059 void par_barrier();
01060
01061
01062
01063
01064
01065
01066
01067 int tool_create(const char *type, int argc, const char **argv);
01068 int tool_delete(int toolnum);
01069 int tool_change_type(int toolnum, const char *type);
01070 int tool_set_position_scale(int toolnum, float newval);
01071 int tool_set_force_scale(int toolnum, float newval);
01072 int tool_set_spring_scale(int toolnum, float newval);
01073
01074
01075
01076
01077
01084 int label_add(const char *category, int num_ids, const int *molids,
01085 const int *atomids, const int *cells, float k, int toggle);
01086
01088 int label_show (const char *category, int n, int onoff);
01089
01092 int label_delete(const char *category, int n);
01093
01095 float label_get_text_size() const;
01096 int label_set_text_size(float);
01097 float label_get_text_thickness() const;
01098 int label_set_text_thickness(float);
01099
01100 int label_set_textoffset(const char *nm, int n, float x, float y);
01101 int label_set_textformat(const char *nm, int n, const char *format);
01102
01104 int next_molid() { return nextMolID++; }
01105
01106
01107
01108
01109
01114 const char *material_add(const char *name, const char *copyfrom);
01115
01117 int material_delete(const char *name);
01118
01121 int material_change(const char *name, int property, float val);
01122
01125 int material_rename(const char *oldname, const char *newname);
01126
01129 int material_restore_default(int);
01130
01132 int mouse_set_mode(int mode, int setting);
01133
01134
01136 int mobile_set_mode(int mode);
01137
01139 int mobile_get_mode();
01140
01142 void mobile_get_client_list(ResizeArray <JString*>* &nick,
01143 ResizeArray <JString*>* &ip, ResizeArray <bool>* &active);
01144
01146 int mobile_network_port(int port);
01147
01149 int mobile_get_network_port();
01150
01152 int mobile_get_APIsupported();
01153
01155 int mobile_set_activeClient(const char *nick, const char *ip);
01156
01158 int mobile_sendMsg(const char *nick, const char *ip, const char *msgType, const char *msg);
01159
01162 void mobile_get_tracker_status(float &tx, float &ty, float &tz,
01163 float &rx, float &ry, float &rz,
01164 int &buttons);
01165
01167 int spaceball_set_mode(int mode);
01168
01170 int spaceball_set_sensitivity(float s);
01171
01173 int spaceball_set_null_region(int nr);
01174
01177 void spaceball_get_tracker_status(float &tx, float &ty, float &tz,
01178 float &rx, float &ry, float &rz,
01179 int &buttons);
01180
01182 void show_stride_message();
01183
01187 char *vmd_choose_file(const char *title,
01188 const char *extension,
01189 const char *extension_label,
01190 int do_save);
01191
01193 static unsigned long get_repserialnum(void);
01194 static unsigned long get_texserialnum(void);
01195
01198 int VMDupdate(int);
01199
01201 static void set_text(const char* str) {
01202 text_message = str;
01203 }
01204 static void append_text(const char* str) {
01205 text_message += str;
01206 }
01207 static void clear_text() {
01208 text_message = JString();
01209 }
01210 static const char* get_text() {
01211 return text_message;
01212 }
01213
01214 void set_mouse_callbacks(int on);
01215
01216 void set_mouse_rocking(int on);
01217
01218
01219 void set_eofexit(int onoff) { eofexit = onoff; }
01220 int get_eofexit() { return eofexit; }
01221
01222 #if defined(VMDXPLOR)
01223
01224 static VMDApp* Obj() { return obj; }
01225 #endif
01226 };
01227
01229 extern "C" void * (*vmd_alloc)(size_t);
01230 extern "C" void (*vmd_dealloc)(void *);
01231 extern "C" void * (*vmd_realloc)(void *, size_t);
01232 extern "C" void * vmd_resize_alloc(void * ptr, size_t oldsize, size_t newsize);
01233 #endif
01234