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, int mpion);
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:
00137 int mpienabled;
00138
00139 #if defined(VMDXPLOR)
00140
00141 static VMDApp* obj;
00142 #endif
00143
00145 static JString text_message;
00146
00148 NameList<VMDMenu *> *menulist;
00149
00151 int nextMolID;
00152
00154 int stride_firsttime;
00155
00157 int eofexit;
00158
00160 int backgroundprocessing;
00161
00162 Mouse *mouse;
00163 DisplayRocker *rocker;
00164
00166 Mobile *mobile;
00167
00169 Spaceball *spaceball;
00170
00171 #ifdef WIN32
00172
00173 Win32Joystick *win32joystick;
00174 #endif
00175
00176 VMDTitle *vmdTitle;
00177 FileRenderList *fileRenderList;
00178 PluginMgr *pluginMgr;
00179
00180 public:
00181 int argc_m;
00182 const char **argv_m;
00183
00184
00185 UIText *uiText;
00186 UIVR *uivr;
00187 IMDMgr *imdMgr;
00188 Animation *anim;
00189 DisplayDevice *display;
00190 Scene *scene;
00191 CUDAAccel *cuda;
00192 PickList *pickList;
00193 PickModeList *pickModeList;
00194 MaterialList *materialList;
00195 Stage *stage;
00196 Axes *axes;
00197 FPS *fps;
00198 CommandQueue *commandQueue;
00199 MoleculeList *moleculeList;
00200 GeometryList *geometryList;
00201 SymbolTable *atomSelParser;
00202 VMDCollab *vmdcollab;
00203 NameList<char *> userKeys;
00204 NameList<char *> userKeyDesc;
00205 int UpdateDisplay;
00206 int exitFlag;
00207 int ResetViewPending;
00208 char nodename[512];
00209 int noderank;
00210 int nodecount;
00211
00214 int highlighted_molid, highlighted_rep;
00215
00216
00217
00218
00219
00225 int background_processing() { return backgroundprocessing; }
00226 void background_processing_clear() { backgroundprocessing = 0; }
00227 void background_processing_set() { backgroundprocessing = 1; }
00228
00233 void deactivate_uitext_stdin();
00234
00235
00236
00237
00238
00241 int activate_menus();
00242
00243 int num_menus();
00244 const char *menu_name(int);
00245 int add_menu(VMDMenu *);
00246 int remove_menu(const char *);
00247
00250 void menu_add_extension(const char *shortname, const char *menu_path);
00251 void menu_remove_extension(const char *shortname);
00252
00255 int menu_status(const char *name);
00256
00258 int menu_location(const char *name, int &x, int &y);
00259
00261 int menu_show(const char *name, int on);
00262
00264 int menu_move(const char *name, int x, int y);
00265
00267 int menu_select_mol(const char *name, int molno);
00268
00269
00270
00271
00272
00273 int filerender_num();
00274 const char *filerender_name(int n);
00275 const char *filerender_prettyname(int n);
00276 int filerender_valid(const char *method);
00277
00279 const char *filerender_shortname_from_prettyname(const char *pretty);
00280
00282 int filerender_has_antialiasing(const char *method);
00283
00285 int filerender_aasamples(const char *method, int aasamples);
00286
00288 int filerender_aosamples(const char *method, int aosamples);
00289
00291 int filerender_has_imagesize(const char *method);
00292
00297 int filerender_imagesize(const char *method, int *imgwidth, int *imgheight);
00298
00304 int filerender_aspectratio(const char *method, float *aspect);
00305
00308 int filerender_numformats(const char *method);
00309
00311 const char *filerender_get_format(const char *method, int i);
00312
00314 const char *filerender_cur_format(const char *method);
00315
00317 int filerender_set_format(const char *method, const char *format);
00318
00320 int filerender_render(const char *method, const char *filename,
00321 const char *extcmd);
00322
00326 const char *filerender_option(const char *method, const char *option);
00327
00329 const char *filerender_default_option(const char *method);
00330
00332 const char *filerender_default_filename(const char *method);
00333
00334
00335
00336
00337
00342 int scene_rotate_by(float angle, char axis, float incr = 0);
00343 int scene_rotate_to(float angle, char axis);
00344
00347 int scene_rotate_by(const float *);
00348 int scene_rotate_to(const float *);
00349
00351 int scene_translate_by(float x, float y, float z);
00352 int scene_translate_to(float x, float y, float z);
00353
00355 int scene_scale_by(float s);
00356 int scene_scale_to(float s);
00357
00360 void scene_resetview_newmoldata();
00361
00364 void scene_resetview();
00365
00369 int scene_rock(char axis, float step, int nsteps = 0);
00370
00372 int scene_rockoff();
00373
00376 int scene_stoprotation();
00377
00391 int animation_num_dirs();
00392 const char *animation_dir_name(int);
00393
00395 int animation_set_dir(int);
00396
00398 int animation_num_styles();
00399 const char *animation_style_name(int);
00400
00402 int animation_set_style(int);
00403
00408 int animation_set_frame(int frame);
00409
00411 int animation_set_stride(int);
00412
00416 int animation_set_speed(float);
00417
00418
00419
00420
00421
00422
00426 vmdplugin_t *get_plugin(const char *type, const char *name);
00427
00431 int list_plugins(PluginList &, const char *type = NULL);
00432
00435 int plugin_dlopen(const char *filename);
00436
00440 void plugin_update();
00441
00442
00443
00444
00445
00447 void display_update_on(int);
00448
00450 int display_update_status();
00451
00453 void display_update();
00454
00456 void display_update_ui();
00457
00458
00459
00460
00461
00462
00463
00465 void display_set_screen_height(float);
00466 float display_get_screen_height();
00467
00469 void display_set_screen_distance(float);
00470 float display_get_screen_distance();
00471
00473 void display_set_position(int x, int y);
00474
00475
00477 void display_set_size(int w, int h);
00478 void display_get_size(int *w, int *h);
00479
00481 int display_set_stereo(const char *mode);
00482
00484 int display_set_stereo_swap(int onoff);
00485
00487 int display_set_cachemode(const char *mode);
00488
00490 int display_set_rendermode(const char *mode);
00491
00493 int display_set_eyesep(float sep);
00494
00496 int display_set_focallen(float flen);
00497
00499 int display_set_projection(const char *proj);
00500
00502 int display_projection_is_perspective(void);
00503
00504 int display_set_aa(int onoff);
00505 int display_set_depthcue(int onoff);
00506 int display_set_culling(int onoff);
00507 int display_set_fps(int onoff);
00508 int display_set_background_mode(int mode);
00509
00510
00511 int display_set_nearclip(float amt, int isdelta);
00512 int display_set_farclip(float amt, int isdelta);
00513
00514 int stage_set_location(const char *);
00515 int stage_set_numpanels(int);
00516 int stage_set_size(float);
00517
00518 int axes_set_location(const char *);
00519
00520 int light_on(int lightnum, int onoff);
00521 int light_highlight(int lightnum, int onoff);
00522 int light_rotate(int lightnum, float amt, char axis);
00523 int light_move(int lightnum, const float *newpos);
00524
00525
00526
00527 int depthcue_set_mode(const char *);
00528 int depthcue_set_start(float);
00529 int depthcue_set_end(float);
00530 int depthcue_set_density(float);
00531
00532 int display_set_shadows(int onoff);
00533 int display_set_ao(int onoff);
00534 int display_set_ao_ambient(float a);
00535 int display_set_ao_direct(float d);
00536
00537
00538
00541
00542
00543
00544
00545
00546
00547
00548
00549
00551 int num_color_categories();
00552
00554 const char *color_category(int);
00555
00559 int color_add_item(const char *cat, const char *item, const char *defcolor);
00560
00562 int num_color_category_items(const char *category);
00563
00565 const char *color_category_item(const char *category, int);
00566
00568 int num_colors();
00569
00571 int num_regular_colors();
00572
00575 const char *color_name(int n);
00576
00581 int color_index(const char *);
00582
00584 int color_value(const char *colorname, float *r, float *g, float *b);
00585
00589 int color_default_value(const char *colorname, float *r, float *g, float *b);
00590
00592 const char *color_mapping(const char *category, const char *item);
00593
00596 const char *color_get_restype(const char *resname);
00597
00602 int color_set_restype(const char *resname, const char *newtype);
00603
00605 int colorscale_info(float *midpoint, float *min, float *max);
00606
00608 int num_colorscale_methods();
00609 int colorscale_method_current();
00610 const char *colorscale_method_name(int);
00611
00613 int colorscale_method_index(const char *);
00614
00616 int get_colorscale_colors(int whichScale,
00617 float min[3], float mid[3], float max[3]);
00619 int set_colorscale_colors(int whichScale,
00620 const float min[3], const float mid[3], const float max[3]);
00621
00622
00625 int color_changename(const char *category, const char *colorname,
00626 const char *color);
00627
00629 int color_get_from_name(const char *category, const char *colorname,
00630 const char **color);
00631
00633 int color_changevalue(const char *color, float r, float g, float b);
00634
00636 int colorscale_setvalues(float midpoint, float min, float max);
00637
00639 int colorscale_setmethod(int method);
00640
00641
00642
00643
00644
00646 int logfile_read(const char *path);
00647
00650 int save_state();
00651
00654 int textinterp_change(const char *interpname);
00655
00656
00657
00658
00659
00661 int num_molecules();
00662
00667 int molecule_new(const char *name, int natoms, int docallbacks=1);
00668
00671 const char *guess_filetype(const char *filename);
00672
00680 int molecule_load(int molid, const char *filename, const char *filetype,
00681 const FileSpec *spec);
00682
00685 int molecule_add_volumetric(int molid, const char *dataname,
00686 const float origin[3], const float xaxis[3], const float yaxis[3],
00687 const float zaxis[3], int xsize, int ysize, int zsize, float *datablock);
00688
00695 int molecule_savetrajectory(int molid, const char *filename,
00696 const char *filetype, const FileSpec *spec);
00697
00700 int molecule_deleteframes(int molid, int first, int last, int stride);
00701
00705 int molecule_index_from_id(int molid);
00706
00710 int molecule_id(int);
00711
00713 int molecule_valid_id(int molid);
00714
00717 int molecule_numatoms(int molid);
00718
00721 int molecule_numframes(int molid);
00722
00725 int molecule_frame(int molid);
00726
00729 int molecule_dupframe(int molid, int frame);
00730
00732 const char *molecule_name(int molid);
00733 int molecule_rename(int molid, const char *newname);
00734
00736 int molecule_cancel_io(int molid);
00737
00739 int molecule_delete(int molid);
00740
00742 int molecule_delete_all(void);
00743
00746 int molecule_activate(int molid, int onoff);
00747 int molecule_is_active(int molid);
00748
00751 int molecule_fix(int molid, int onoff);
00752 int molecule_is_fixed(int molid);
00753
00756 int molecule_display(int molid, int onoff);
00757 int molecule_is_displayed(int molid);
00758
00761 int molecule_make_top(int molid);
00762
00764 int molecule_top();
00765
00767 int num_molreps(int molid);
00768
00769
00770
00771
00772
00773
00775 const char *molrep_get_style(int molid, int repid);
00776 int molrep_set_style(int molid, int repid, const char *style);
00777
00779 const char *molrep_get_color(int molid, int repid);
00780 int molrep_set_color(int molid, int repid, const char *color);
00781
00783 const char *molrep_get_selection(int molid, int repid);
00784 int molrep_set_selection(int molid, int repid, const char *selection);
00785
00788 int molrep_numselected(int molid, int repid);
00789
00791 const char *molrep_get_material(int molid, int repid);
00792 int molrep_set_material(int molid, int repid, const char *material);
00793
00796 int num_clipplanes();
00797
00800 int molrep_get_clipplane(int molid, int repid, int clipid, float *center,
00801 float *normal, float *color, int *mode);
00803 int molrep_set_clipcenter(int molid, int repid, int clipid,
00804 const float *center);
00805 int molrep_set_clipnormal(int molid, int repid, int clipid,
00806 const float *normal);
00807 int molrep_set_clipcolor(int molid, int repid, int clipid,
00808 const float *color);
00809 int molrep_set_clipstatus(int molid, int repid, int clipid, int onoff);
00810
00814 int molrep_set_smoothing(int molid, int repid, int n);
00815
00818 int molrep_get_smoothing(int molid, int repid);
00819
00820
00821
00822
00823
00825 const char *molrep_get_name(int molid, int repid);
00826
00829 int molrep_get_by_name(int molid, const char *);
00830
00832 int molrep_set_pbc(int molid, int repid, int pbc);
00833
00835 int molrep_get_pbc(int molid, int repid);
00836
00838 int molrep_set_pbc_images(int molid, int repid, int n);
00839
00841 int molrep_get_pbc_images(int molid, int repid);
00842
00845 int molrep_show(int molid, int repid, int onff);
00846
00848 int molrep_is_shown(int molid, int repid);
00849
00850
00851
00852
00853
00854
00855
00856 const char *molecule_get_style();
00857 int molecule_set_style(const char *style);
00858
00859 const char *molecule_get_color();
00860 int molecule_set_color(const char *color);
00861
00862 const char *molecule_get_selection();
00863 int molecule_set_selection(const char *selection);
00864
00865 const char *molecule_get_material();
00866 int molecule_set_material(const char *material);
00867
00870 int molecule_addrep(int molid);
00871
00873 int molecule_modrep(int molid, int repid);
00874
00876 int molrep_delete(int molid, int repid);
00877
00879
00880
00881
00882 int molrep_get_selupdate(int molid, int repid);
00883 int molrep_set_selupdate(int molid, int repid, int onoff);
00885
00887
00888 int molrep_get_colorupdate(int molid, int repid);
00889 int molrep_set_colorupdate(int molid, int repid, int onoff);
00891
00893
00894 int molrep_get_scaleminmax(int molid, int repid, float *min, float *max);
00895 int molrep_set_scaleminmax(int molid, int repid, float min, float max);
00896 int molrep_reset_scaleminmax(int molid, int repid);
00898
00902 int molrep_set_drawframes(int molid, int repid, const char *framesel);
00903 const char *molrep_get_drawframes(int molid, int repid);
00904
00907 int molecule_set_dataset_flag(int molid, const char *dataflagstr, int setval);
00908
00913 int molecule_reanalyze(int molid);
00914
00917 int molecule_bondsrecalc(int molid);
00918
00922 int molecule_ssrecalc(int molid);
00923
00926 int molecule_orblocalize(int molid, int waveid);
00927
00928
00929
00930
00931
00934 int imd_connect(int molid, const char *host, int port);
00935
00937 int imd_connected(int molid);
00938
00941 int imd_sendforces(int, const int *, const float *);
00942
00944 int imd_disconnect(int molid);
00945
00946
00947
00948
00949
00951 const char * par_name() { return nodename; }
00952
00954 int par_rank() { return noderank; }
00955
00957 int par_size() { return nodecount; }
00958
00960 void par_barrier();
00961
00962
00963
00964
00965
00966 int tool_create(const char *type, int argc, const char **argv);
00967 int tool_delete(int toolnum);
00968 int tool_change_type(int toolnum, const char *type);
00969 int tool_set_position_scale(int toolnum, float newval);
00970 int tool_set_force_scale(int toolnum, float newval);
00971 int tool_set_spring_scale(int toolnum, float newval);
00972
00973
00974
00975
00976
00983 int label_add(const char *category, int num_ids, const int *molids,
00984 const int *atomids, const int *cells, float k, int toggle);
00985
00987 int label_show (const char *category, int n, int onoff);
00988
00991 int label_delete(const char *category, int n);
00992
00994 float label_get_text_size() const;
00995 int label_set_text_size(float);
00996 float label_get_text_thickness() const;
00997 int label_set_text_thickness(float);
00998
00999 int label_set_textoffset(const char *nm, int n, float x, float y);
01000 int label_set_textformat(const char *nm, int n, const char *format);
01001
01003 int next_molid() { return nextMolID++; }
01004
01005
01006
01007
01008
01013 const char *material_add(const char *name, const char *copyfrom);
01014
01016 int material_delete(const char *name);
01017
01020 int material_change(const char *name, int property, float val);
01021
01024 int material_rename(const char *oldname, const char *newname);
01025
01028 int material_restore_default(int);
01029
01031 int mouse_set_mode(int mode, int setting);
01032
01033
01035 int mobile_set_mode(int mode);
01036
01038 int mobile_get_mode();
01039
01041 void mobile_get_client_list(ResizeArray <JString*>* &nick,
01042 ResizeArray <JString*>* &ip, ResizeArray <bool>* &active);
01043
01045 int mobile_network_port(int port);
01046
01048 int mobile_get_network_port();
01049
01051 int mobile_get_APIsupported();
01052
01054 int mobile_set_activeClient(const char *nick, const char *ip);
01055
01057 int mobile_sendMsg(const char *nick, const char *ip, const char *msgType, const char *msg);
01058
01061 void mobile_get_tracker_status(float &tx, float &ty, float &tz,
01062 float &rx, float &ry, float &rz,
01063 int &buttons);
01064
01066 int spaceball_set_mode(int mode);
01067
01069 int spaceball_set_sensitivity(float s);
01070
01072 int spaceball_set_null_region(int nr);
01073
01076 void spaceball_get_tracker_status(float &tx, float &ty, float &tz,
01077 float &rx, float &ry, float &rz,
01078 int &buttons);
01079
01081 void show_stride_message();
01082
01086 char *vmd_choose_file(const char *title,
01087 const char *extension,
01088 const char *extension_label,
01089 int do_save);
01090
01092 static unsigned long get_repserialnum(void);
01093 static unsigned long get_texserialnum(void);
01094
01097 int VMDupdate(int);
01098
01100 static void set_text(const char* str) {
01101 text_message = str;
01102 }
01103 static void append_text(const char* str) {
01104 text_message += str;
01105 }
01106 static void clear_text() {
01107 text_message = JString();
01108 }
01109 static const char* get_text() {
01110 return text_message;
01111 }
01112
01113 void set_mouse_callbacks(int on);
01114
01115 void set_mouse_rocking(int on);
01116
01117
01118 void set_eofexit(int onoff) { eofexit = onoff; }
01119 int get_eofexit() { return eofexit; }
01120
01121 #if defined(VMDXPLOR)
01122
01123 static VMDApp* Obj() { return obj; }
01124 #endif
01125 };
01126
01128 extern "C" void * (*vmd_alloc)(size_t);
01129 extern "C" void (*vmd_dealloc)(void *);
01130 extern "C" void * (*vmd_realloc)(void *, size_t);
01131 extern "C" void * vmd_resize_alloc(void * ptr, size_t oldsize, size_t newsize);
01132 #endif
01133