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

VMDApp.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2008 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 /***************************************************************************
00009  * RCS INFORMATION:
00010  *
00011  *      $RCSfile: VMDApp.h,v $
00012  *      $Author: johns $        $Locker:  $             $State: Exp $
00013  *      $Revision: 1.196 $      $Date: 2008/06/20 06:36:44 $
00014  *
00015  ***************************************************************************/
00016 
00017 // VMDApp
00018 // Instantiate a new VMD object!
00019 
00020 #ifndef VMD_APP_H
00021 #define VMD_APP_H
00022 
00023 #ifdef VMDSWIG
00024 #ifdef SWIG_init
00025 #undef SWIG_init
00026 #endif
00027 #define SWIG_init initvmd
00028 #endif
00029 
00030 #include "PluginMgr.h"
00031 class Plugin;
00032 class CUDAAccel;
00033 class DisplayDevice;
00034 class SymbolTable;
00035 class Scene;
00036 class PickList;
00037 class PickModeList;
00038 class Axes;
00039 class DisplayRocker;
00040 class CommandQueue;
00041 class UIText;
00042 class MoleculeList;
00043 class GeometryList;
00044 class IMDMgr; 
00045 class Stage;
00046 class Mouse; 
00047 class FPS;
00048 class Animation;
00049 class Spaceball; 
00050 #ifdef WIN32
00051 class Win32Joystick;
00052 #endif
00053 class UIVR; 
00054 class FileRenderList;
00055 class VMDTitle;
00056 class MaterialList;
00057 class VMDMenu;
00058 class VMDCollab;
00059 
00060 #include <string.h>  // for size_t
00061 #include "NameList.h"
00062 #include "JString.h"
00063 #include "vmdplugin.h"
00064 
00065 #define VMD_CHECK_EVENTS  1
00066 #define VMD_IGNORE_EVENTS 0
00067 
00069 struct FileSpec {
00070   int autobonds;    
00071   int filebonds;    
00072   int first;        
00073   int last;         
00074   int stride;       
00075   int waitfor;      
00076   int nvolsets;     
00077   int *setids;      
00078   int *selection;   
00079 
00080   FileSpec() {
00081     autobonds = 1;  // allow automatic bond determination when necessary
00082     filebonds = 1;  // honor bonds read from loaded files
00083     first = 0;      // start with first timestep
00084     last = -1;      // end with last timestep
00085     stride = 1;     // do every frame
00086     waitfor = 1;    // wait for all frames to load
00087     nvolsets = -1;  // all volumetric sets
00088     setids = NULL;  // but no explicit list
00089     selection = NULL; // default to all atom selected
00090   }
00091 
00092   FileSpec(const FileSpec &s) {
00093     autobonds=s.autobonds;
00094     filebonds=s.filebonds;
00095     first=s.first;
00096     last=s.last;
00097     stride=s.stride;
00098     waitfor=s.waitfor;
00099     nvolsets=s.nvolsets;
00100     if (nvolsets > 0) {
00101       setids = new int[nvolsets];
00102       memcpy(setids, s.setids, nvolsets*sizeof(int));
00103     } else {
00104       setids = NULL;
00105     }
00106     // selections aren't implemented in file loading, and this copy
00107     // constructor is used only by CmdMolLoad.  Therefore we're ok to
00108     // just ignore the selection field when making a copy of FileSpec.
00109     selection = NULL;
00110   }
00111 
00112   ~FileSpec() {
00113     delete [] setids;
00114   }
00115 };
00116 
00117 
00119 class VMDApp {
00120 public:
00122   VMDApp(int argc, char **argv);
00123 
00130   int VMDinit(int, char **, const char *, int * dispLoc, int * dispSize);
00131   
00132   ~VMDApp();
00133 
00136   void VMDexit(const char *exitmsg, int exitcode, int pauseseconds);
00137  
00138 private:
00140   static JString text_message;
00141 
00143   NameList<VMDMenu *> *menulist; 
00144 
00146   int nextMolID;
00147 
00149   int stride_firsttime;
00150 
00152   int eofexit;  
00153 
00155   int backgroundprocessing;
00156 
00157   Mouse *mouse;
00158   DisplayRocker *rocker;
00159 
00161   Spaceball *spaceball;
00162 
00163 #ifdef WIN32
00164 
00165   Win32Joystick *win32joystick;
00166 #endif
00167 
00168   VMDTitle *vmdTitle;
00169   FileRenderList *fileRenderList;
00170   PluginMgr *pluginMgr;
00171 
00172 public:
00173 #ifndef VMDSWIG_INTERFACE
00174   int argc_m;           
00175   const char **argv_m;  
00176 
00177   // de facto Global variables, by virtual of being public in this singleton
00178   UIText *uiText;               
00179   UIVR *uivr;                   
00180   IMDMgr *imdMgr;               
00181   Animation *anim;              
00182   DisplayDevice *display;       
00183   Scene *scene;                 
00184   CUDAAccel *cuda;              
00185   PickList *pickList;           
00186   PickModeList *pickModeList;   
00187   MaterialList *materialList;   
00188   Stage *stage;                 
00189   Axes *axes;                   
00190   FPS *fps;                     
00191   CommandQueue *commandQueue;   
00192   MoleculeList *moleculeList;   
00193   GeometryList *geometryList;   
00194   SymbolTable *atomSelParser;   
00195   VMDCollab *vmdcollab;         
00196   NameList<char *> userKeys;    
00197   NameList<char *> userKeyDesc; 
00198   int UpdateDisplay;            
00199   int exitFlag;                 
00200   int ResetViewPending;         
00201 
00204   int highlighted_molid, highlighted_rep;
00205 #endif
00206 
00207   //
00208   // NO member variables beyond this point!
00209   //
00210 
00216   int  background_processing() { return backgroundprocessing; }
00217   void background_processing_clear() { backgroundprocessing = 0; }
00218   void background_processing_set()   { backgroundprocessing = 1; }
00219 
00224   void deactivate_uitext_stdin();
00225 
00226   //
00227   // methods for querying the state of the VMD menus
00228   //
00229 
00232   int activate_menus();
00233 
00234   int num_menus();               
00235   const char *menu_name(int);    
00236   int add_menu(VMDMenu *);    //< add menu.  Return success.
00237   int remove_menu(const char *); 
00238 
00241   void menu_add_extension(const char *shortname, const char *menu_path);
00242   void menu_remove_extension(const char *shortname);
00243   
00246   int menu_status(const char *name);
00247 
00249   int menu_location(const char *name, int &x, int &y);
00250  
00252   int menu_show(const char *name, int on);
00253 
00255   int menu_move(const char *name, int x, int y);
00256   
00258   int menu_select_mol(const char *name, int molno);
00259   
00260   // 
00261   // methods for exporting to external rendering systems
00262   //
00263   
00264   int filerender_num();                     
00265   const char *filerender_name(int n);       
00266   int filerender_valid(const char *method); 
00267 
00269   int filerender_has_antialiasing(const char *method); 
00270 
00272   int filerender_aalevel(const char *method, int aalevel);
00273 
00275   int filerender_has_imagesize(const char *method);
00276 
00281   int filerender_imagesize(const char *method, int *imgwidth, int *imgheight);
00282 
00288   int filerender_aspectratio(const char *method, float *aspect);
00289 
00292   int filerender_numformats(const char *method); 
00293 
00295   const char *filerender_get_format(const char *method, int i);
00296 
00298   const char *filerender_cur_format(const char *method);
00299 
00301   int filerender_set_format(const char *method, const char *format);
00302 
00304   int filerender_render(const char *method, const char *filename,
00305                         const char *extcmd);
00306 
00310   const char *filerender_option(const char *method, const char *option);
00311   
00313   const char *filerender_default_option(const char *method);
00314 
00316   const char *filerender_default_filename(const char *method);
00317 
00318   // 
00319   // methods for rotating, translating, and scaling the scene.  Return success
00320   //
00321 
00326   int scene_rotate_by(float angle, char axis, float incr = 0);
00327   int scene_rotate_to(float angle, char axis);
00328 
00331   int scene_rotate_by(const float *); // takes a float[16]
00332   int scene_rotate_to(const float *); // takes a float[16]
00333 
00335   int scene_translate_by(float x, float y, float z);
00336   int scene_translate_to(float x, float y, float z);
00337 
00339   int scene_scale_by(float s);
00340   int scene_scale_to(float s);
00341 
00344   void scene_resetview_newmoldata();
00345 
00348   void scene_resetview();
00349  
00353   int scene_rock(char axis, float step, int nsteps = 0); 
00354  
00356   int scene_rockoff();
00357 
00360   int scene_stoprotation();
00361 
00375   int animation_num_dirs();
00376   const char *animation_dir_name(int);
00377 
00379   int animation_set_dir(int);
00380 
00382   int animation_num_styles();
00383   const char *animation_style_name(int);
00384 
00386   int animation_set_style(int);
00387 
00392   int animation_set_frame(int frame);
00393 
00395   int animation_set_stride(int);
00396 
00400   int animation_set_speed(float);
00401 
00402 
00403   //
00404   // Methods for getting plugins
00405   //
00406 
00410   vmdplugin_t *get_plugin(const char *type, const char *name);
00411   
00415   int list_plugins(PluginList &, const char *type = NULL);
00416 
00419   int plugin_dlopen(const char *filename);
00420 
00424   void plugin_update();
00425 
00426   //
00427   // display update methods
00428   //
00429 
00431   void display_update_on(int);
00432 
00434   int display_update_status();
00435 
00437   void display_update();
00438   
00440   void display_update_ui();
00441 
00442   //
00443   // methods for setting display properties
00444   // These should be considered provisional; they are here primarily to
00445   // allow startup options to be processed outside of VMDApp.
00446   //
00447 
00449   void display_set_screen_height(float);
00450   float display_get_screen_height();
00451    
00453   void display_set_screen_distance(float);
00454   float display_get_screen_distance();
00455  
00457   void display_set_position(int x, int y);
00458   //void display_get_position(int *x, int *y); // XXX doesn't work...
00459  
00461   void display_set_size(int w, int h);
00462   void display_get_size(int *w, int *h);
00463 
00465   int display_set_stereo(const char *mode);
00466 
00468   int display_set_cachemode(const char *mode);
00469 
00471   int display_set_rendermode(const char *mode);
00472 
00474   int display_set_eyesep(float sep);
00475 
00477   int display_set_focallen(float flen);
00478 
00480   int display_set_projection(const char *proj);
00481 
00483   int display_projection_is_perspective(void);
00484 
00485   int display_set_aa(int onoff);
00486   int display_set_depthcue(int onoff);
00487   int display_set_culling(int onoff);
00488   int display_set_fps(int onoff);
00489   int display_set_background_mode(int mode);
00490 
00491   // set clipping plane position.  if isdelta, then treat as offset.
00492   int display_set_nearclip(float amt, int isdelta);
00493   int display_set_farclip(float amt, int isdelta);
00494 
00495   int stage_set_location(const char *);
00496   int stage_set_numpanels(int);
00497 
00498   int axes_set_location(const char *);
00499 
00500   int light_on(int lightnum, int onoff);
00501   int light_highlight(int lightnum, int onoff);
00502   int light_rotate(int lightnum, float amt, char axis);
00503   int light_move(int lightnum, const float *newpos);
00504 
00505   int depthcue_set_mode(const char *);
00506   int depthcue_set_start(float);
00507   int depthcue_set_end(float);
00508   int depthcue_set_density(float);
00509 
00510   // 
00513   void display_titlescreen();
00514 
00515   // 
00516   // Methods for setting color properties.  We have a set of color 
00517   // _categories_ (Display, Axes...), each of which contains one or more
00518   // _items_ (Display->Background, Axes->X, Y, Z, ...).  Each item has a
00519   // color _name_ mapped to it (blue, red, ...).
00520   //
00521 
00523   int num_color_categories();
00524 
00526   const char *color_category(int);
00527 
00531   int color_add_item(const char *cat, const char *item, const char *defcolor); 
00532   
00534   int num_color_category_items(const char *category);
00535 
00537   const char *color_category_item(const char *category, int);
00538 
00540   int num_colors();
00541 
00543   int num_regular_colors();
00544 
00547   const char *color_name(int n);
00548 
00553   int color_index(const char *);
00554 
00556   int color_value(const char *colorname, float *r, float *g, float *b);
00557 
00561   int color_default_value(const char *colorname, float *r, float *g, float *b);
00562   
00564   const char *color_mapping(const char *category, const char *item);
00565  
00568   const char *color_get_restype(const char *resname);
00569 
00574   int color_set_restype(const char *resname, const char *newtype);
00575 
00577   int colorscale_info(float *midpoint, float *min, float *max); 
00578 
00580   int num_colorscale_methods();
00581   int colorscale_method_current();
00582   const char *colorscale_method_name(int);
00583 
00585   int colorscale_method_index(const char *);
00586 
00588   int get_colorscale_colors(int whichScale, 
00589       float min[3], float mid[3], float max[3]);
00591   int set_colorscale_colors(int whichScale, 
00592       const float min[3], const float mid[3], const float max[3]);
00593   
00594 
00597   int color_changename(const char *category, const char *colorname,
00598                        const char *color);
00599   
00601   int color_get_from_name(const char *category, const char *colorname,
00602                        const char **color);
00603  
00605   int color_changevalue(const char *color, float r, float g, float b);
00606 
00608   int colorscale_setvalues(float midpoint, float min, float max);
00609 
00611   int colorscale_setmethod(int method);
00612 
00613   //
00614   // Command logging methods
00615   //
00616   
00618   int logfile_read(const char *path);
00619   
00622   int save_state();
00623  
00626   int textinterp_change(const char *interpname);
00627 
00628   // 
00629   // Methods for editing and querying molecules and molecular representations
00630   //
00631  
00633   int num_molecules();
00634 
00637   int molecule_new(const char *name);
00638 
00641   const char *guess_filetype(const char *filename);
00642 
00650   int molecule_load(int molid, const char *filename, const char *filetype, 
00651       const FileSpec *spec);
00652 
00655   int molecule_add_volumetric(int molid, const char *dataname, 
00656     const float origin[3], const float xaxis[3], const float yaxis[3],
00657     const float zaxis[3], int xsize, int ysize, int zsize, float *datablock);
00658 
00665   int molecule_savetrajectory(int molid, const char *filename, 
00666                               const char *filetype, const FileSpec *spec);
00667 
00670   int molecule_deleteframes(int molid, int first, int last, int stride);
00671   
00675   int molecule_id(int);
00676 
00678   int molecule_valid_id(int molid);
00679 
00682   int molecule_numatoms(int molid);
00683 
00686   int molecule_numframes(int molid);
00687 
00690   int molecule_frame(int molid);
00691 
00694   int molecule_dupframe(int molid, int frame);
00695   
00697   const char *molecule_name(int molid);
00698   int molecule_rename(int molid, const char *newname);
00699 
00701   int molecule_cancel_io(int molid);
00702   
00704   int molecule_delete(int molid);
00705 
00707   int molecule_delete_all(void);
00708   
00711   int molecule_activate(int molid, int onoff);
00712   int molecule_is_active(int molid);
00713  
00716   int molecule_fix(int molid, int onoff);
00717   int molecule_is_fixed(int molid);
00718  
00721   int molecule_display(int molid, int onoff);
00722   int molecule_is_displayed(int molid);
00723 
00726   int molecule_make_top(int molid);
00727 
00729   int molecule_top(); 
00730 
00732   int num_molreps(int molid);
00733 
00734   //
00735   // For the molrep methods, repid is not unique; it applies to different reps
00736   // if reps are created and then deleted.  Too bad.
00737   //
00738 
00740   const char *molrep_get_style(int molid, int repid); 
00741   int molrep_set_style(int molid, int repid, const char *style);
00742  
00744   const char *molrep_get_color(int molid, int repid); 
00745   int molrep_set_color(int molid, int repid, const char *color);
00746 
00748   const char *molrep_get_selection(int molid, int repid); 
00749   int molrep_set_selection(int molid, int repid, const char *selection);
00750 
00753   int molrep_numselected(int molid, int repid);
00754 
00756   const char *molrep_get_material(int molid, int repid); 
00757   int molrep_set_material(int molid, int repid, const char *material);
00758 
00761   int num_clipplanes();
00762 
00765   int molrep_get_clipplane(int molid, int repid, int clipid, float *center, 
00766                            float *normal, float *color, int *mode);
00768   int molrep_set_clipcenter(int molid, int repid, int clipid, 
00769                             const float *center);
00770   int molrep_set_clipnormal(int molid, int repid, int clipid, 
00771                             const float *normal);
00772   int molrep_set_clipcolor(int molid, int repid, int clipid, 
00773                             const float *color);
00774   int molrep_set_clipstatus(int molid, int repid, int clipid, int onoff);
00775   
00779   int molrep_set_smoothing(int molid, int repid, int n);
00780 
00783   int molrep_get_smoothing(int molid, int repid);
00784   
00785   // methods for retrieving reps by name rather than index.  The name is
00786   // guaranteed to be unique within a given molecule and follow the rep
00787   // around even when its order or index changes.
00788   
00790   const char *molrep_get_name(int molid, int repid);
00791   
00794   int molrep_get_by_name(int molid, const char *);
00795  
00797   int molrep_set_pbc(int molid, int repid, int pbc);
00798 
00800   int molrep_get_pbc(int molid, int repid);
00801 
00803   int molrep_set_pbc_images(int molid, int repid, int n);
00804 
00806   int molrep_get_pbc_images(int molid, int repid);
00807 
00810   int molrep_show(int molid, int repid, int onff);
00811 
00813   int molrep_is_shown(int molid, int repid);
00814 
00815   // The next few commands set/get a default representation parameter; these
00816   // parameters define the properties of the rep which would be added on the
00817   // next call to molecule_addrep().  They exactly parallel the methods for
00818   // changing an existing representation except that no molid or repid is
00819   // specified.
00820   
00821   const char *molecule_get_style(); 
00822   int molecule_set_style(const char *style);
00823  
00824   const char *molecule_get_color(); 
00825   int molecule_set_color(const char *color);
00826 
00827   const char *molecule_get_selection(); 
00828   int molecule_set_selection(const char *selection);
00829 
00830   const char *molecule_get_material(); 
00831   int molecule_set_material(const char *material);
00832 
00835   int molecule_addrep(int molid);
00836   
00838   int molecule_modrep(int molid, int repid);
00839 
00841   int molrep_delete(int molid, int repid);
00842  
00844 
00845 
00846 
00847   int molrep_get_selupdate(int molid, int repid);
00848   int molrep_set_selupdate(int molid, int repid, int onoff);
00850 
00852 
00853   int molrep_get_colorupdate(int molid, int repid);
00854   int molrep_set_colorupdate(int molid, int repid, int onoff);
00856 
00858 
00859   int molrep_get_scaleminmax(int molid, int repid, float *min, float *max);
00860   int molrep_set_scaleminmax(int molid, int repid, float min, float max);
00861   int molrep_reset_scaleminmax(int molid, int repid);
00863   
00867   int molrep_set_drawframes(int molid, int repid, const char *framesel);
00868   const char *molrep_get_drawframes(int molid, int repid);
00869 
00874   int molecule_reanalyze(int molid);
00875 
00878   int molecule_bondsrecalc(int molid);
00879 
00883   int molecule_ssrecalc(int molid);
00884    
00885   // 
00886   // IMD methods
00887   //
00888   
00891   int imd_connect(int molid, const char *host, int port);
00892 
00894   int imd_connected(int molid);
00895 
00898   int imd_sendforces(int, const int *, const float *);
00899 
00901   int imd_disconnect(int molid);
00902 
00903   //
00904   // Tool methods
00905   //
00906 
00907   int tool_create(const char *type, int argc, const char **argv);
00908   int tool_delete(int toolnum);
00909   int tool_change_type(int toolnum, const char *type);
00910   int tool_set_position_scale(int toolnum, float newval);
00911   int tool_set_force_scale(int toolnum, float newval);
00912   int tool_set_spring_scale(int toolnum, float newval);
00913 
00914   //
00915   // Methods for adding/querying labels
00916   //
00917 
00924   int label_add(const char *category, int num_ids, const int *molids, 
00925       const int *atomids, const int *cells, float k, int toggle);
00926 
00928   int label_show (const char *category, int n, int onoff);
00929 
00932   int label_delete(const char *category, int n);
00933 
00935   float label_get_textsize() const;
00936   int label_set_textsize(float);
00937 
00938   int label_set_textoffset(const char *nm, int n, float x, float y);
00939   int label_set_textformat(const char *nm, int n, const char *format);
00940 
00942   int next_molid() { return nextMolID++; }
00943 
00944   //
00945   // Material methods
00946   //
00947 
00952   const char *material_add(const char *name, const char *copyfrom);
00953 
00955   int material_delete(const char *name);
00956 
00959   int material_change(const char *name, int property, float val);
00960 
00963   int material_rename(const char *oldname, const char *newname);
00964 
00967   int material_restore_default(int);
00968 
00970   int mouse_set_mode(int mode, int setting);
00971 
00973   int spaceball_set_mode(int mode);
00974 
00976   int spaceball_set_sensitivity(float s);
00977 
00979   int spaceball_set_null_region(int nr);
00980 
00983   void spaceball_get_tracker_status(float &tx, float &ty, float &tz, 
00984                                     float &rx, float &ry, float &rz, 
00985                                     int &buttons);
00986 
00988   void show_stride_message();
00989 
00993   char *vmd_choose_file(const char *title, 
00994                 const char *extension,
00995                 const char *extension_label,
00996                 int do_save);
00997 
00999   static unsigned long get_repserialnum(void);
01000   static unsigned long get_texserialnum(void);
01001 
01004   int VMDupdate(int);
01005 
01007   static void set_text(const char* str) { 
01008      text_message = str; 
01009   }
01010   static void append_text(const char* str) { 
01011      text_message += str; 
01012   }
01013   static void clear_text() { 
01014      text_message = JString(); 
01015   }
01016   static const char* get_text() { 
01017      return text_message; 
01018   }
01019 
01020   void set_mouse_callbacks(int on);
01021 
01022   void set_mouse_rocking(int on);
01023 
01024   // get/set eofexit status
01025   void set_eofexit(int onoff) { eofexit = onoff; }
01026   int get_eofexit() { return eofexit; }
01027 };
01028 
01030   extern void * (*vmd_alloc)(size_t);
01031   extern void (*vmd_dealloc)(void *);
01032   extern void * (*vmd_realloc)(void *, size_t);
01033   extern void * vmd_resize_alloc(void * ptr, size_t oldsize, size_t newsize);
01034 #endif
01035 

Generated on Sat Sep 6 01:27:16 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002