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

P_TugTool.C

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_TugTool.C,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.54 $       $Date: 2019/01/17 21:21:01 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  * This is Paul's new Tracker code -- pgrayson@ks.uiuc.edu
00019  *
00020  *
00021  ***************************************************************************/
00022 
00023 #include "P_TugTool.h"
00024 #include "utilities.h"
00025 #include "Displayable.h"
00026 
00027 TugTool::TugTool(int id, VMDApp *vmdapp, Displayable *disp) 
00028 : Tool(id, vmdapp, disp) {
00029   int i;
00030   for(i=0;i<3;i++) offset[i]=0;
00031   tugging=0;
00032   springscale = 1.0;
00033 }
00034 
00035 void TugTool::do_event() {
00036 
00037   if(!tugging) { // we haven't started tugging, update UIVR
00038     tool_location_update();
00039   }
00040 
00041   if (istugging()) {  // Tugging is enabled...
00042     if (!tugging || !is_targeted()) { // but we're not tugging now
00043       if(!target(TARGET_TUG, tugged_pos, 0)) {
00044         // Didn't pick anything, so return
00045         tugging = 0;
00046         return;
00047       }
00048       tugging = 1;
00049       // We're starting the force field, so set the offset
00050       vec_sub(offset, Tool::position(), tugged_pos);
00051       start_tug();
00052     }
00053     target(TARGET_TUG, tugged_pos, 1);
00054     // Apply the force field...
00055     float offset_tugged_pos[3]; // offset+tugged_pos
00056     vec_add(offset_tugged_pos,offset,tugged_pos);
00057     set_tug_constraint(offset_tugged_pos);
00058     
00059     // and send the proper force to UIVR for display and possible
00060     // export
00061     float diff[3];
00062     vec_sub(diff, Tool::position(), offset_tugged_pos);
00063     // diff now is in my units, but we should do it in mol units
00064     vec_scale(diff,dtool->scale/getTargetScale(),diff);
00065     // scale by the force scaling spring constant
00066     vec_scale(diff,forcescale,diff); 
00067     do_tug(diff);
00068   }
00069   else if (tugging) { // Tugging has been disabled, so turn it off.
00070     let_go();
00071     tugging = 0;
00072     forceoff();
00073     offset[0]=offset[1]=offset[2]=0;
00074   }
00075 }
00076 
00077 void TugTool::set_tug_constraint(float *cpos) {
00078   setconstraint(50, cpos);
00079   sendforce();
00080 }
00081 
00082 void TugTool::do_tug(float *force) {
00083   tug(force);
00084 }
00085 

Generated on Fri Apr 26 02:44:02 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002