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

P_Tool.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr                                                                       
00003  *cr            (C) Copyright 1995-2019 The Board of Trustees of the           
00004  *cr                        University of Illinois                       
00005  *cr                         All Rights Reserved                        
00006  *cr                                                                   
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: P_Tool.h,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.67 $       $Date: 2019/01/17 21:21:01 $
00015  *
00016  ***************************************************************************/
00017 #ifndef P_TOOL_H
00018 #define P_TOOL_H
00019 
00020 #include "UIObject.h"
00021 #include "JString.h"
00022 #include "Matrix4.h"
00023 
00024 class Displayable;
00025 class VMDTracker;
00026 class Buttons;
00027 class Feedback;
00028 class SensorConfig;
00029 
00030 #define TARGET_TUG  0
00031 #define TARGET_GRAB 1
00032 
00038 class Tool : public UIObject {
00039 public:
00040   Tool(int id, VMDApp *, Displayable *aParentDisplayable);
00041   virtual ~Tool();
00042 
00044   int id() const { return my_id; }
00045 
00046   int steal_sensor(Tool *from); 
00047 
00053   int add_tracker(VMDTracker *, const SensorConfig *);
00054   int add_feedback(Feedback *, const SensorConfig *);
00055   int add_buttons(Buttons *, const SensorConfig *);
00056 
00058   int remove_device(const char *device);
00059 
00061   void getdevices(char **ret);
00062   const char *get_tracker() const { return tracker ? (const char *)trackerDev : NULL; }
00063   const char *get_feedback() const { return feedback ? (const char *)feedbackDev : NULL; }
00064   const char *get_buttons() const { return buttons ? (const char *)buttonDev : NULL; }
00065 
00067   float getscale();
00068   void setscale(float scale);
00069 
00072   float getspringscale() const { return springscale; }
00073   void setspringscale(float s) { springscale = s;    }
00074 
00078   float getforcescale() { return forcescale; }
00079   void setforcescale(float f) { forcescale = f; }
00080 
00082   const float *getoffset();
00083   void setoffset(float *offset);
00084 
00086   virtual const float *position() const;
00087 
00089   virtual const Matrix4 *orientation();
00090 
00092   virtual int isgrabbing();
00093 
00095   int alive() const { return amalive; }
00096 
00098   void kill() { amalive = 0; }
00099 
00101   virtual const char *type_name() const = 0; 
00102 
00103   virtual int check_event();
00104 
00105 protected:
00106   float forcescale;       
00107   float springscale;      
00108 
00109 private:
00110   int amalive;            
00111 
00112   VMDTracker *tracker;
00113   Feedback *feedback;
00114   Buttons *buttons;
00115   JString trackerDev, feedbackDev, buttonDev;
00116 
00117   int lost_sensor;        
00118 
00119   void update();
00120   void clear_devices();
00121 
00122   float pos[3];           
00123   Matrix4 orient;         
00124   const int my_id;        
00125 
00126   // Picking state for this tool.
00127   int targeted_molecule;  
00128   int targeted_atom;      
00129   char *targeted_rep;     
00130 
00131   Matrix4 last_rot;
00132   float last_pos[3];
00133   float sel_total_mass;
00134 
00135 public:
00136   // Turning grabbing on and off is still done from within P_UIVR, so these
00137   // need to be public for now.
00138   int grabs;
00139   void dograb();
00140   void ungrab();
00141 
00144   int assign_rep(int mol, int rep);
00145 
00147   int get_rep_molid() const { return targeted_molecule; }
00148   
00150   const char *get_rep_name() const { return targeted_rep; }
00151 
00153   void clear_rep() { 
00154     delete [] targeted_rep;
00155     targeted_molecule = -1;
00156     targeted_rep = NULL;
00157     sel_total_mass = 0;
00158     let_go();
00159   }
00160 
00161 protected:
00164   Displayable *dtool;
00165   
00168   virtual void do_event() {}
00169 
00170   // These are all the methods for querying and manipulating the picking state.
00171 
00174   int target(int target_type, float *mpos, int just_checking);
00175 
00177   void let_go() { if (!targeted_rep) targeted_molecule = -1; }
00178 
00180   int is_targeted() const { return targeted_molecule != -1; }
00181 
00183   int get_targeted_atom(int *molret, int *atomret) const;
00184 
00186   void tool_location_update();
00187 
00189   float getTargetScale();
00190 
00192   void tug(const float *);
00193 
00195   int dimension();
00196 
00198   void setplaneconstraint(float k, const float *point, const float *normal);
00199   void addplaneconstraint(float k, const float *point, const float *normal);
00200   void setconstraint(float k, const float *point); 
00201   void setforcefield(const float *origin, const float *force, 
00202                      const float *jacobian);
00203 
00206   void sendforce();
00207 
00209   void forceoff();
00210 
00212   int wasgrabbing;
00213 };
00214 
00215 #endif
00216 

Generated on Thu Apr 18 02:45:23 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002