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 Plugin;
00025 class CUDAAccel;
00026 class DisplayDevice;
00027 class SymbolTable;
00028 class Scene;
00029 class PickList;
00030 class PickModeList;
00031 class Axes;
00032 class DisplayRocker;
00033 class CommandQueue;
00034 class UIText;
00035 class MoleculeList;
00036 class GeometryList;
00037 class IMDMgr;
00038 class Stage;
00039 class Mouse;
00040 class FPS;
00041 class Animation;
00042 class Mobile;
00043 class Spaceball;
00044 #ifdef WIN32
00045 class Win32Joystick;
00046 #endif
00047 class UIVR;
00048 class FileRenderList;
00049 class VMDTitle;
00050 class MaterialList;
00051 class VMDMenu;
00052 class VMDCollab;
00053
00054 #include <string.h>
00055 #include "NameList.h"
00056 #include "JString.h"
00057 #include "vmdplugin.h"
00058
00059 #define VMD_CHECK_EVENTS 1
00060 #define VMD_IGNORE_EVENTS 0
00061
00063 struct FileSpec {
00064 int autobonds;
00065 int filebonds;
00066 int first;
00067 int last;
00068 int stride;
00069 int waitfor;
00070 int nvolsets;
00071 int *setids;
00072 int *selection;
00073
00074 FileSpec() {
00075 autobonds = 1;
00076 filebonds = 1;
00077 first = 0;
00078 last = -1;
00079 stride = 1;
00080 waitfor = 1;
00081 nvolsets = -1;
00082 setids = NULL;
00083 selection = NULL;
00084 }
00085
00086 FileSpec(const FileSpec &s) {
00087 autobonds=s.autobonds;
00088 filebonds=s.filebonds;
00089 first=s.first;
00090 last=s.last;
00091 stride=s.stride;
00092 waitfor=s.waitfor;
00093 nvolsets=s.nvolsets;
00094 if (nvolsets > 0) {
00095 setids = new int[nvolsets];
00096 memcpy(setids, s.setids, nvolsets*sizeof(int));
00097 } else {
00098 setids = NULL;
00099 }
00100
00101
00102
00103 selection = NULL;
00104 }
00105
00106 ~FileSpec() {
00107 delete [] setids;
00108 }
00109 };
00110
00111
00113 class VMDApp {
00114 public:
00116 VMDApp(int argc, char **argv);
00117
00124 int VMDinit(int, char **, const char *, int * dispLoc, int * dispSize);
00125
00126 ~VMDApp();
00127
00130 void VMDexit(const char *exitmsg, int exitcode, int pauseseconds);
00131
00132 private:
00133 #if defined(VMDXPLOR)
00134
00135 static VMDApp* obj;
00136 #endif
00137
00139 static JString text_message;
00140
00142 NameList<VMDMenu *> *menulist;
00143
00145 int nextMolID;
00146
00148 int stride_firsttime;
00149
00151 int eofexit;
00152
00154 int backgroundprocessing;
00155
00156 Mouse *mouse;
00157 DisplayRocker *rocker;
00158
00160 Mobile *mobile;
00161
00163 Spaceball *spaceball;
00164
00165 #ifdef WIN32
00166
00167 Win32Joystick *win32joystick;
00168 #endif
00169
00170 VMDTitle *vmdTitle;
00171 FileRenderList *fileRenderList;
00172 PluginMgr *pluginMgr;
00173
00174 public:
00175 int argc_m;
00176 const char **argv_m;
00177
00178
00179 UIText *uiText;
00180 UIVR *uivr;
00181 IMDMgr *imdMgr;
00182 Animation *anim;
00183 DisplayDevice *display;
00184 Scene *scene;
00185 CUDAAccel *cuda;
00186 PickList *pickList;
00187 PickModeList *pickModeList;
00188 MaterialList *materialList;
00189 Stage *stage;
00190 Axes *axes;
00191 FPS *fps;
00192 CommandQueue *commandQueue;
00193 MoleculeList *moleculeList;
00194 GeometryList *geometryList;
00195 SymbolTable *atomSelParser;
00196 VMDCollab *vmdcollab;
00197 NameList<char *> userKeys;
00198 NameList<char *> userKeyDesc;
00199 int UpdateDisplay;
00200 int exitFlag;
00201 int ResetViewPending;
00202 char nodename[512];
00203 int noderank;
00204 int nodecount;
00205
00208 int highlighted_molid, highlighted_rep;
00209
00210
00211
00212
00213
00219 int background_processing() { return backgroundprocessing; }
00220 void background_processing_clear() { backgroundprocessing = 0; }
00221 void background_processing_set() { backgroundprocessing = 1; }
00222
00227 void deactivate_uitext_stdin();
00228
00229
00230
00231
00232
00235 int activate_menus();
00236
00237 int num_menus();
00238 const char *menu_name(int);
00239 int add_menu(VMDMenu *);
00240 int remove_menu(const char *);
00241
00244 void menu_add_extension(const char *shortname, const char *menu_path);
00245 void menu_remove_extension(const char *shortname);
00246
00249 int menu_status(const char *name);
00250
00252 int menu_location(const char *name, int &x, int &y);
00253
00255 int menu_show(const char *name, int on);
00256
00258 int menu_move(const char *name, int x, int y);
00259
00261 int menu_select_mol(const char *name, int molno);
00262
00263
00264
00265
00266
00267 int filerender_num();
00268 const char *filerender_name(int n);
00269 const char *filerender_prettyname(int n);
00270 int filerender_valid(const char *method);
00271
00273 const char *filerender_shortname_from_prettyname(const char *pretty);
00274
00276 int filerender_has_antialiasing(const char *method);
00277
00279 int filerender_aasamples(const char *method, int aasamples);
00280
00282 int filerender_aosamples(const char *method, int aosamples);
00283
00285 int filerender_has_imagesize(const char *method);
00286
00291 int filerender_imagesize(const char *method, int *imgwidth, int *imgheight);
00292
00298 int filerender_aspectratio(const char *method, float *aspect);
00299
00302 int filerender_numformats(const char *method);
00303
00305 const char *filerender_get_format(const char *method, int i);
00306
00308 const char *filerender_cur_format(const char *method);
00309
00311 int filerender_set_format(const char *method, const char *format);
00312
00314 int filerender_render(const char *method, const char *filename,
00315 const char *extcmd);
00316
00320 const char *filerender_option(const char *method, const char *option);
00321
00323 const char *filerender_default_option(const char *method);
00324
00326 const char *filerender_default_filename(const char *method);
00327
00328
00329
00330
00331
00336 int scene_rotate_by(float angle, char axis, float incr = 0);
00337 int scene_rotate_to(float angle, char axis);
00338
00341 int scene_rotate_by(const float *);
00342 int scene_rotate_to(const float *);
00343
00345 int scene_translate_by(float x, float y, float z);
00346 int scene_translate_to(float x, float y, float z);
00347
00349 int scene_scale_by(float s);
00350 int scene_scale_to(float s);
00351
00354 void scene_resetview_newmoldata();
00355
00358 void scene_resetview();
00359
00363 int scene_rock(char axis, float step, int nsteps = 0);
00364
00366 int scene_rockoff();
00367
00370 int scene_stoprotation();
00371
00385 int animation_num_dirs();
00386 const char *animation_dir_name(int);
00387
00389 int animation_set_dir(int);
00390
00392 int animation_num_styles();
00393 const char *animation_style_name(int);
00394
00396 int animation_set_style(int);
00397
00402 int animation_set_frame(int frame);
00403
00405 int animation_set_stride(int);
00406
00410 int animation_set_speed(float);
00411
00412
00413
00414
00415
00416
00420 vmdplugin_t *get_plugin(const char *type, const char *name);
00421
00425 int list_plugins(PluginList &, const char *type = NULL);
00426
00429 int plugin_dlopen(const char *filename);
00430
00434 void plugin_update();
00435
00436
00437
00438
00439
00441 void display_update_on(int);
00442
00444 int display_update_status();
00445
00447 void display_update();
00448
00450 void display_update_ui();
00451
00452
00453
00454
00455
00456
00457
00459 void display_set_screen_height(float);
00460 float display_get_screen_height();
00461
00463 void display_set_screen_distance(float);
00464 float display_get_screen_distance();
00465
00467 void display_set_position(int x, int y);
00468
00469
00471 void display_set_size(int w, int h);
00472 void display_get_size(int *w, int *h);
00473
00475 int display_set_stereo(const char *mode);
00476
00478 int display_set_stereo_swap(int onoff);
00479
00481 int display_set_cachemode(const char *mode);
00482
00484 int display_set_rendermode(const char *mode);
00485
00487 int display_set_eyesep(float sep);
00488
00490 int display_set_focallen(float flen);
00491
00493 int display_set_projection(const char *proj);
00494
00496 int display_projection_is_perspective(void);
00497
00498 int display_set_aa(int onoff);
00499 int display_set_depthcue(int onoff);
00500 int display_set_culling(int onoff);
00501 int display_set_fps(int onoff);
00502 int display_set_background_mode(int mode);
00503
00504
00505 int display_set_nearclip(float amt, int isdelta);
00506 int display_set_farclip(float amt, int isdelta);
00507
00508 int stage_set_location(const char *);
00509 int stage_set_numpanels(int);
00510 int stage_set_size(float);
00511
00512 int axes_set_location(const char *);
00513
00514 int light_on(int lightnum, int onoff);
00515 int light_highlight(int lightnum, int onoff);
00516 int light_rotate(int lightnum, float amt, char axis);
00517 int light_move(int lightnum, const float *newpos);
00518
00519
00520
00521 int depthcue_set_mode(const char *);
00522 int depthcue_set_start(float);
00523 int depthcue_set_end(float);
00524 int depthcue_set_density(float);
00525
00526 int display_set_shadows(int onoff);
00527 int display_set_ao(int onoff);
00528 int display_set_ao_ambient(float a);
00529 int display_set_ao_direct(float d);
00530
00531
00532
00535
00536
00537
00538
00539
00540
00541
00542
00543
00545 int num_color_categories();
00546
00548 const char *color_category(int);
00549
00553 int color_add_item(const char *cat, const char *item, const char *defcolor);
00554
00556 int num_color_category_items(const char *category);
00557
00559 const char *color_category_item(const char *category, int);
00560
00562 int num_colors();
00563
00565 int num_regular_colors();
00566
00569 const char *color_name(int n);
00570
00575 int color_index(const char *);
00576
00578 int color_value(const char *colorname, float *r, float *g, float *b);
00579
00583 int color_default_value(const char *colorname, float *r, float *g, float *b);
00584
00586 const char *color_mapping(const char *category, const char *item);
00587
00590 const char *color_get_restype(const char *resname);
00591
00596 int color_set_restype(const char *resname, const char *newtype);
00597
00599 int colorscale_info(float *midpoint, float *min, float *max);
00600
00602 int num_colorscale_methods();
00603 int colorscale_method_current();
00604 const char *colorscale_method_name(int);
00605
00607 int colorscale_method_index(const char *);
00608
00610 int get_colorscale_colors(int whichScale,
00611 float min[3], float mid[3], float max[3]);
00613 int set_colorscale_colors(int whichScale,
00614 const float min[3], const float mid[3], const float max[3]);
00615
00616
00619 int color_changename(const char *category, const char *colorname,
00620 const char *color);
00621
00623 int color_get_from_name(const char *category, const char *colorname,
00624 const char **color);
00625
00627 int color_changevalue(const char *color, float r, float g, float b);
00628
00630 int colorscale_setvalues(float midpoint, float min, float max);
00631
00633 int colorscale_setmethod(int method);
00634
00635
00636
00637
00638
00640 int logfile_read(const char *path);
00641
00644 int save_state();
00645
00648 int textinterp_change(const char *interpname);
00649
00650
00651
00652
00653
00655 int num_molecules();
00656
00661 int molecule_new(const char *name, int natoms, int docallbacks=1);
00662
00665 const char *guess_filetype(const char *filename);
00666
00674 int molecule_load(int molid, const char *filename, const char *filetype,
00675 const FileSpec *spec);
00676
00679 int molecule_add_volumetric(int molid, const char *dataname,
00680 const float origin[3], const float xaxis[3], const float yaxis[3],
00681 const float zaxis[3], int xsize, int ysize, int zsize, float *datablock);
00682
00689 int molecule_savetrajectory(int molid, const char *filename,
00690 const char *filetype, const FileSpec *spec);
00691
00694 int molecule_deleteframes(int molid, int first, int last, int stride);
00695
00699 int molecule_index_from_id(int molid);
00700
00704 int molecule_id(int);
00705
00707 int molecule_valid_id(int molid);
00708
00711 int molecule_numatoms(int molid);
00712
00715 int molecule_numframes(int molid);
00716
00719 int molecule_frame(int molid);
00720
00723 int molecule_dupframe(int molid, int frame);
00724
00726 const char *molecule_name(int molid);
00727 int molecule_rename(int molid, const char *newname);
00728
00730 int molecule_cancel_io(int molid);
00731
00733 int molecule_delete(int molid);
00734
00736 int molecule_delete_all(void);
00737
00740 int molecule_activate(int molid, int onoff);
00741 int molecule_is_active(int molid);
00742
00745 int molecule_fix(int molid, int onoff);
00746 int molecule_is_fixed(int molid);
00747
00750 int molecule_display(int molid, int onoff);
00751 int molecule_is_displayed(int molid);
00752
00755 int molecule_make_top(int molid);
00756
00758 int molecule_top();
00759
00761 int num_molreps(int molid);
00762
00763
00764
00765
00766
00767
00769 const char *molrep_get_style(int molid, int repid);
00770 int molrep_set_style(int molid, int repid, const char *style);
00771
00773 const char *molrep_get_color(int molid, int repid);
00774 int molrep_set_color(int molid, int repid, const char *color);
00775
00777 const char *molrep_get_selection(int molid, int repid);
00778 int molrep_set_selection(int molid, int repid, const char *selection);
00779
00782 int molrep_numselected(int molid, int repid);
00783
00785 const char *molrep_get_material(int molid, int repid);
00786 int molrep_set_material(int molid, int repid, const char *material);
00787
00790 int num_clipplanes();
00791
00794 int molrep_get_clipplane(int molid, int repid, int clipid, float *center,
00795 float *normal, float *color, int *mode);
00797 int molrep_set_clipcenter(int molid, int repid, int clipid,
00798 const float *center);
00799 int molrep_set_clipnormal(int molid, int repid, int clipid,
00800 const float *normal);
00801 int molrep_set_clipcolor(int molid, int repid, int clipid,
00802 const float *color);
00803 int molrep_set_clipstatus(int molid, int repid, int clipid, int onoff);
00804
00808 int molrep_set_smoothing(int molid, int repid, int n);
00809
00812 int molrep_get_smoothing(int molid, int repid);
00813
00814
00815
00816
00817
00819 const char *molrep_get_name(int molid, int repid);
00820
00823 int molrep_get_by_name(int molid, const char *);
00824
00826 int molrep_set_pbc(int molid, int repid, int pbc);
00827
00829 int molrep_get_pbc(int molid, int repid);
00830
00832 int molrep_set_pbc_images(int molid, int repid, int n);
00833
00835 int molrep_get_pbc_images(int molid, int repid);
00836
00839 int molrep_show(int molid, int repid, int onff);
00840
00842 int molrep_is_shown(int molid, int repid);
00843
00844
00845
00846
00847
00848
00849
00850 const char *molecule_get_style();
00851 int molecule_set_style(const char *style);
00852
00853 const char *molecule_get_color();
00854 int molecule_set_color(const char *color);
00855
00856 const char *molecule_get_selection();
00857 int molecule_set_selection(const char *selection);
00858
00859 const char *molecule_get_material();
00860 int molecule_set_material(const char *material);
00861
00864 int molecule_addrep(int molid);
00865
00867 int molecule_modrep(int molid, int repid);
00868
00870 int molrep_delete(int molid, int repid);
00871
00873
00874
00875
00876 int molrep_get_selupdate(int molid, int repid);
00877 int molrep_set_selupdate(int molid, int repid, int onoff);
00879
00881
00882 int molrep_get_colorupdate(int molid, int repid);
00883 int molrep_set_colorupdate(int molid, int repid, int onoff);
00885
00887
00888 int molrep_get_scaleminmax(int molid, int repid, float *min, float *max);
00889 int molrep_set_scaleminmax(int molid, int repid, float min, float max);
00890 int molrep_reset_scaleminmax(int molid, int repid);
00892
00896 int molrep_set_drawframes(int molid, int repid, const char *framesel);
00897 const char *molrep_get_drawframes(int molid, int repid);
00898
00901 int molecule_set_dataset_flag(int molid, const char *dataflagstr, int setval);
00902
00907 int molecule_reanalyze(int molid);
00908
00911 int molecule_bondsrecalc(int molid);
00912
00916 int molecule_ssrecalc(int molid);
00917
00920 int molecule_orblocalize(int molid, int waveid);
00921
00922
00923
00924
00925
00928 int imd_connect(int molid, const char *host, int port);
00929
00931 int imd_connected(int molid);
00932
00935 int imd_sendforces(int, const int *, const float *);
00936
00938 int imd_disconnect(int molid);
00939
00940
00941
00942
00943
00945 const char * par_name() { return nodename; }
00946
00948 int par_rank() { return noderank; }
00949
00951 int par_size() { return nodecount; }
00952
00954 void par_barrier();
00955
00956
00957
00958
00959
00960 int tool_create(const char *type, int argc, const char **argv);
00961 int tool_delete(int toolnum);
00962 int tool_change_type(int toolnum, const char *type);
00963 int tool_set_position_scale(int toolnum, float newval);
00964 int tool_set_force_scale(int toolnum, float newval);
00965 int tool_set_spring_scale(int toolnum, float newval);
00966
00967
00968
00969
00970
00977 int label_add(const char *category, int num_ids, const int *molids,
00978 const int *atomids, const int *cells, float k, int toggle);
00979
00981 int label_show (const char *category, int n, int onoff);
00982
00985 int label_delete(const char *category, int n);
00986
00988 float label_get_text_size() const;
00989 int label_set_text_size(float);
00990 float label_get_text_thickness() const;
00991 int label_set_text_thickness(float);
00992
00993 int label_set_textoffset(const char *nm, int n, float x, float y);
00994 int label_set_textformat(const char *nm, int n, const char *format);
00995
00997 int next_molid() { return nextMolID++; }
00998
00999
01000
01001
01002
01007 const char *material_add(const char *name, const char *copyfrom);
01008
01010 int material_delete(const char *name);
01011
01014 int material_change(const char *name, int property, float val);
01015
01018 int material_rename(const char *oldname, const char *newname);
01019
01022 int material_restore_default(int);
01023
01025 int mouse_set_mode(int mode, int setting);
01026
01027
01029 int mobile_set_mode(int mode);
01030
01032 int mobile_get_mode();
01033
01035 void mobile_get_client_list(ResizeArray <JString*>* &nick,
01036 ResizeArray <JString*>* &ip, ResizeArray <bool>* &active);
01037
01039 int mobile_network_port(int port);
01040
01042 int mobile_get_network_port();
01043
01045 int mobile_get_APIsupported();
01046
01048 int mobile_set_activeClient(const char *nick, const char *ip);
01049
01051 int mobile_sendMsg(const char *nick, const char *ip, const char *msgType, const char *msg);
01052
01055 void mobile_get_tracker_status(float &tx, float &ty, float &tz,
01056 float &rx, float &ry, float &rz,
01057 int &buttons);
01058
01060 int spaceball_set_mode(int mode);
01061
01063 int spaceball_set_sensitivity(float s);
01064
01066 int spaceball_set_null_region(int nr);
01067
01070 void spaceball_get_tracker_status(float &tx, float &ty, float &tz,
01071 float &rx, float &ry, float &rz,
01072 int &buttons);
01073
01075 void show_stride_message();
01076
01080 char *vmd_choose_file(const char *title,
01081 const char *extension,
01082 const char *extension_label,
01083 int do_save);
01084
01086 static unsigned long get_repserialnum(void);
01087 static unsigned long get_texserialnum(void);
01088
01091 int VMDupdate(int);
01092
01094 static void set_text(const char* str) {
01095 text_message = str;
01096 }
01097 static void append_text(const char* str) {
01098 text_message += str;
01099 }
01100 static void clear_text() {
01101 text_message = JString();
01102 }
01103 static const char* get_text() {
01104 return text_message;
01105 }
01106
01107 void set_mouse_callbacks(int on);
01108
01109 void set_mouse_rocking(int on);
01110
01111
01112 void set_eofexit(int onoff) { eofexit = onoff; }
01113 int get_eofexit() { return eofexit; }
01114
01115 #if defined(VMDXPLOR)
01116
01117 static VMDApp* Obj() { return obj; }
01118 #endif
01119 };
01120
01122 extern "C" void * (*vmd_alloc)(size_t);
01123 extern "C" void (*vmd_dealloc)(void *);
01124 extern "C" void * (*vmd_realloc)(void *, size_t);
01125 extern "C" void * vmd_resize_alloc(void * ptr, size_t oldsize, size_t newsize);
01126 #endif
01127