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

Tool Class Reference

A Tool represents a virtual device used to manipulate objects on the screen. Tools use input from VMDTracker, Feedback, and Button devices and draw a pointer on the screen. Tools can give up their devices to another tool to effectively allow a tool to change its type on the fly. More...

#include <P_Tool.h>

Inheritance diagram for Tool:

UIObject GrabTool JoystickTool PinchTool PrintTool RotateTool SpringTool TugTool List of all members.

Public Methods

 Tool (int id, VMDApp *, Displayable *aParentDisplayable)
virtual ~Tool ()
int id () const
 return unqiue id. More...

int steal_sensor (Tool *from)
 steal devices from another tool. More...

int add_tracker (VMDTracker *, const SensorConfig *)
int add_feedback (Feedback *, const SensorConfig *)
int add_buttons (Buttons *, const SensorConfig *)
int remove_device (const char *device)
 Remove the device with the given name. For backwards compatibility only. More...

void getdevices (char **ret)
 Get the names of the devices used by this tool. More...

const char * get_tracker () const
const char * get_feedback () const
const char * get_buttons () const
float getscale ()
 Get/set the coordinate scaling used by this tool's Tracker. More...

void setscale (float scale)
float getspringscale () const
 The spring scaling controls the stiffness of the force feedback device. Its units should be real N/m. More...

void setspringscale (float s)
float getforcescale ()
 The force scaling scales the _exported force, i.e. the force which is sent to UIVR and/or an external simulation. It is a spring constant, in . More...

void setforcescale (float f)
const float * getoffset ()
 Get/set the position offset used by this tool's tracker. More...

void setoffset (float *offset)
virtual const float * position () const
 return the position of this tool. More...

virtual const Matrix4orientation ()
 return the orientation of this tool. More...

virtual int isgrabbing ()
 True iff the tool is grabbing something. More...

int alive () const
 True iff there is a valid sensor for this tool. More...

void kill ()
 Invalidate sensor/tool. More...

virtual const char * type_name () const=0
 return the name of this tool. Must be unique to all Tool subclasses! More...

virtual int check_event ()
 check for an event, and queue it if found. Return TRUE if an event was generated. More...

void dograb ()
void ungrab ()
int assign_rep (int mol, int rep)
 Use the given rep as the targeted atoms, overriding picked atoms. Return success. More...

int get_rep_molid () const
 Get the molid of the currently selected rep; -1 if none. More...

const char * get_rep_name () const
 Get the name of the currently selected rep; NULL if none. More...

void clear_rep ()
 Clear the selection and go back to picking atoms by hand. More...


Public Attributes

int grabs

Protected Methods

virtual void do_event ()
 Subclasses should override this method to perform tool-specific actions every display loop. More...

int target (int target_type, float *mpos, int just_checking)
 See if we're currently picking anything, and if so, update the pick variables. Return true if anything was picked. More...

void let_go ()
 Cease picking. More...

int is_targeted () const
 Test for picking. More...

int get_targeted_atom (int *molret, int *atomret) const
 See what was picked last without acquiring a new target. More...

void tool_location_update ()
 Trigger callbacks based on current position. More...

float getTargetScale ()
 Returns the scale factor of the currently picked molecule. More...

void tug (const float *)
 Apply the given force to the current target. More...

int dimension ()
 Dimension of the tracker device in use. More...

void setplaneconstraint (float k, const float *point, const float *normal)
 Set force field parameters. More...

void addplaneconstraint (float k, const float *point, const float *normal)
void setconstraint (float k, const float *point)
void setforcefield (const float *origin, const float *force, const float *jacobian)
void sendforce ()
 Deliver specified force to the feedback device. XXX Maybe this should be taken care of automatically in the update loop. More...

void forceoff ()
 Stop applying force. More...


Protected Attributes

float forcescale
 scales force sent to the atoms. More...

float springscale
 scales force sent to the feedback device. More...

Displayabledtool
 The visual representation of this tool. It's not private because for some reason the TugTool needs access to some of its members. More...

int wasgrabbing
 XXX Should be private variable; gets set to isgrabbing() by RotateTool. More...


Detailed Description

A Tool represents a virtual device used to manipulate objects on the screen. Tools use input from VMDTracker, Feedback, and Button devices and draw a pointer on the screen. Tools can give up their devices to another tool to effectively allow a tool to change its type on the fly.

Definition at line 38 of file P_Tool.h.


Constructor & Destructor Documentation

Tool::Tool int    id,
VMDApp  ,
Displayable   aParentDisplayable
 

Definition at line 66 of file P_Tool.C.

References dtool, forcescale, NULL, springscale, and wasgrabbing.

Tool::~Tool   [virtual]
 

Definition at line 88 of file P_Tool.C.

References dtool.


Member Function Documentation

int Tool::add_buttons Buttons  ,
const SensorConfig  
 

Definition at line 123 of file P_Tool.C.

References SensorConfig::getdevice, and Buttons::start.

Referenced by UIVR::set_buttons.

int Tool::add_feedback Feedback  ,
const SensorConfig  
 

Definition at line 114 of file P_Tool.C.

References SensorConfig::getdevice, and Feedback::start.

Referenced by UIVR::set_feedback.

int Tool::add_tracker VMDTracker  ,
const SensorConfig  
 

Add a device. Also starts the device. Add a NULL device to remove the item. Return success, defined as either successful removal or starting of the device.

Definition at line 105 of file P_Tool.C.

References SensorConfig::getdevice, and VMDTracker::start.

Referenced by UIVR::set_tracker.

void Tool::addplaneconstraint float    k,
const float *    point,
const float *    normal
[protected]
 

Definition at line 520 of file P_Tool.C.

References Feedback::addplaneconstraint, VMDTracker::get_offset, VMDTracker::get_scale, n, and springscale.

Referenced by RotateTool::do_event.

int Tool::alive   const [inline]
 

True iff there is a valid sensor for this tool.

Definition at line 95 of file P_Tool.h.

Referenced by ToolFltkMenu::reset_tool_list, and ToolFltkMenu::select_tool.

int Tool::assign_rep int    mol,
int    rep
 

Use the given rep as the targeted atoms, overriding picked atoms. Return success.

Definition at line 239 of file P_Tool.C.

References UIObject::app, DrawMolItem::atomSel, clear_rep, DrawMolecule::component, AtomSel::firstsel, AtomSel::lastsel, BaseMolecule::mass, MoleculeList::mol_from_id, VMDApp::moleculeList, DrawMolItem::name, AtomSel::on, PickList::pick_callback_clear, VMDApp::pickList, and stringdup.

Referenced by UIVR::act_on_command.

int Tool::check_event void    [virtual]
 

check for an event, and queue it if found. Return TRUE if an event was generated.

Reimplemented from UIObject.

Definition at line 205 of file P_Tool.C.

References do_event, dtool, Displayable::glob_trans_off, Displayable::glob_trans_on, orientation, position, Displayable::rot_off, Displayable::rot_on, Displayable::set_glob_trans, and Displayable::set_rot.

void Tool::clear_rep   [inline]
 

Clear the selection and go back to picking atoms by hand.

Definition at line 153 of file P_Tool.h.

References let_go, and NULL.

Referenced by UIVR::act_on_command, assign_rep, and target.

int Tool::dimension   [protected]
 

Dimension of the tracker device in use.

Definition at line 502 of file P_Tool.C.

References VMDTracker::dimension, and dimension.

Referenced by dimension, RotateTool::do_event, and JoystickTool::do_event.

virtual void Tool::do_event   [inline, protected, virtual]
 

Subclasses should override this method to perform tool-specific actions every display loop.

Reimplemented in GrabTool.

Definition at line 168 of file P_Tool.h.

Referenced by check_event.

void Tool::dograb  
 

Definition at line 417 of file P_Tool.C.

References UIObject::app, Displayable::fix, Displayable::globt, BaseMolecule::id, id, Matrix4::inverse, Matrix4::mat, MoleculeList::mol_from_id, MoleculeList::molecule, VMDApp::molecule_fix, VMDApp::moleculeList, Matrix4::multmatrix, Matrix4::multpoint3d, NULL, MoleculeList::num, orientation, position, VMDApp::scene_rotate_by, VMDApp::scene_translate_by, Displayable::unfix, vec_add, and vec_sub.

void Tool::forceoff   [protected]
 

Stop applying force.

Definition at line 563 of file P_Tool.C.

References Feedback::forceoff.

Referenced by SpringTool::do_event, TugTool::do_event, RotateTool::do_event, PinchTool::do_event, JoystickTool::do_event, and GrabTool::do_event.

const char* Tool::get_buttons   const [inline]
 

Definition at line 64 of file P_Tool.h.

References NULL.

Referenced by ToolFltkMenu::select_tool.

const char* Tool::get_feedback   const [inline]
 

Definition at line 63 of file P_Tool.h.

References NULL.

Referenced by ToolFltkMenu::select_tool.

int Tool::get_rep_molid   const [inline]
 

Get the molid of the currently selected rep; -1 if none.

Definition at line 147 of file P_Tool.h.

Referenced by ToolFltkMenu::update_toolrep_choosers.

const char* Tool::get_rep_name   const [inline]
 

Get the name of the currently selected rep; NULL if none.

Definition at line 150 of file P_Tool.h.

Referenced by ToolFltkMenu::update_toolrep_choosers.

int Tool::get_targeted_atom int *    molret,
int *    atomret
const [protected]
 

See what was picked last without acquiring a new target.

Definition at line 265 of file P_Tool.C.

References NULL.

Referenced by SpringTool::do_event.

const char* Tool::get_tracker   const [inline]
 

Definition at line 62 of file P_Tool.h.

References NULL.

Referenced by ToolFltkMenu::select_tool.

void Tool::getdevices char **    ret
 

Get the names of the devices used by this tool.

Definition at line 163 of file P_Tool.C.

References NULL.

Referenced by text_cmd_tool.

float Tool::getforcescale   [inline]
 

The force scaling scales the _exported force, i.e. the force which is sent to UIVR and/or an external simulation. It is a spring constant, in .

Definition at line 78 of file P_Tool.h.

References forcescale.

Referenced by ToolFltkMenu::select_tool.

const float * Tool::getoffset  
 

Get/set the position offset used by this tool's tracker.

Definition at line 234 of file P_Tool.C.

References VMDTracker::get_offset, and NULL.

Referenced by ToolFltkMenu::select_tool, and text_cmd_tool.

float Tool::getscale  
 

Get/set the coordinate scaling used by this tool's Tracker.

Definition at line 226 of file P_Tool.C.

References VMDTracker::get_scale.

Referenced by ToolFltkMenu::select_tool, and text_cmd_tool.

float Tool::getspringscale   const [inline]
 

The spring scaling controls the stiffness of the force feedback device. Its units should be real N/m.

Definition at line 72 of file P_Tool.h.

References springscale.

Referenced by ToolFltkMenu::select_tool.

float Tool::getTargetScale   [protected]
 

Returns the scale factor of the currently picked molecule.

Definition at line 495 of file P_Tool.C.

References UIObject::app, MoleculeList::mol_from_id, VMDApp::moleculeList, and Displayable::scale.

Referenced by SpringTool::do_event, and TugTool::do_event.

int Tool::id void    const [inline]
 

return unqiue id.

Definition at line 44 of file P_Tool.h.

Referenced by PrintTool::do_event, dograb, and ungrab.

int Tool::is_targeted   const [inline, protected]
 

Test for picking.

Definition at line 180 of file P_Tool.h.

Referenced by SpringTool::do_event, and TugTool::do_event.

int Tool::isgrabbing   [virtual]
 

True iff the tool is grabbing something.

Reimplemented in PinchTool.

Definition at line 171 of file P_Tool.C.

References Buttons::state.

Referenced by RotateTool::do_event, JoystickTool::do_event, and GrabTool::do_event.

void Tool::kill   [inline]
 

Invalidate sensor/tool.

Definition at line 98 of file P_Tool.h.

void Tool::let_go   [inline, protected]
 

Cease picking.

Definition at line 177 of file P_Tool.h.

Referenced by clear_rep, SpringTool::do_event, TugTool::do_event, RotateTool::do_event, PinchTool::do_event, JoystickTool::do_event, and target.

const Matrix4 * Tool::orientation   [virtual]
 

return the orientation of this tool.

Reimplemented in RotateTool.

Definition at line 181 of file P_Tool.C.

References NULL.

Referenced by check_event, PrintTool::do_event, PinchTool::do_event, GrabTool::do_event, dograb, RotateTool::orientation, and text_cmd_tool.

const float * Tool::position   const [virtual]
 

return the position of this tool.

Reimplemented in JoystickTool.

Definition at line 176 of file P_Tool.C.

References NULL.

Referenced by check_event, SpringTool::do_event, TugTool::do_event, RotateTool::do_event, PrintTool::do_event, PinchTool::do_event, JoystickTool::do_event, GrabTool::do_event, dograb, RotateTool::position, JoystickTool::position, sendforce, target, text_cmd_tool, and tool_location_update.

int Tool::remove_device const char *    device
 

Remove the device with the given name. For backwards compatibility only.

Definition at line 133 of file P_Tool.C.

References NULL.

Referenced by UIVR::act_on_command.

void Tool::sendforce   [protected]
 

Deliver specified force to the feedback device. XXX Maybe this should be taken care of automatically in the update loop.

Definition at line 560 of file P_Tool.C.

References position, and Feedback::sendforce.

Referenced by RotateTool::do_event, PinchTool::do_event, JoystickTool::do_event, and GrabTool::do_event.

void Tool::setconstraint float    k,
const float *    point
[protected]
 

Definition at line 532 of file P_Tool.C.

References Feedback::addconstraint, VMDTracker::get_offset, VMDTracker::get_scale, springscale, and Feedback::zeroforce.

Referenced by JoystickTool::do_event.

void Tool::setforcefield const float *    origin,
const float *    force,
const float *    jacobian
[protected]
 

Definition at line 545 of file P_Tool.C.

References Feedback::addforcefield, force, VMDTracker::get_scale, springscale, and Feedback::zeroforce.

Referenced by GrabTool::do_event.

void Tool::setforcescale float    f [inline]
 

Definition at line 79 of file P_Tool.h.

References forcescale.

Referenced by UIVR::set_force_scale.

void Tool::setoffset float *    offset
 

Definition at line 231 of file P_Tool.C.

References VMDTracker::set_offset.

Referenced by UIVR::act_on_command.

void Tool::setplaneconstraint float    k,
const float *    point,
const float *    normal
[protected]
 

Set force field parameters.

Definition at line 507 of file P_Tool.C.

References Feedback::addplaneconstraint, VMDTracker::get_offset, VMDTracker::get_scale, n, springscale, and Feedback::zeroforce.

Referenced by RotateTool::do_event, and PinchTool::do_event.

void Tool::setscale float    scale
 

Definition at line 223 of file P_Tool.C.

References VMDTracker::set_scale.

Referenced by UIVR::set_position_scale.

void Tool::setspringscale float    s [inline]
 

Reimplemented in PinchTool.

Definition at line 73 of file P_Tool.h.

References springscale.

Referenced by UIVR::set_spring_scale, SpringTool::setspringscale, TugTool::setspringscale, and PinchTool::setspringscale.

int Tool::steal_sensor Tool *    from
 

steal devices from another tool.

Definition at line 149 of file P_Tool.C.

References buttonDev, buttons, feedback, feedbackDev, forcescale, lost_sensor, springscale, tracker, and trackerDev.

Referenced by UIVR::change_type.

int Tool::target int    target_type,
float *    mpos,
int    just_checking
[protected]
 

See if we're currently picking anything, and if so, update the pick variables. Return true if anything was picked.

Definition at line 282 of file P_Tool.C.

References UIObject::app, DrawMolItem::atomSel, MoleculeList::check_pickable, clear_rep, DrawMolecule::component, DrawMolecule::current, VMDApp::display, AtomSel::firstsel, Displayable::globt, BaseMolecule::id, AtomSel::lastsel, let_go, BaseMolecule::mass, MoleculeList::mol_from_id, VMDApp::molecule_numframes, VMDApp::moleculeList, VMDApp::molrep_get_by_name, Matrix4::multpoint3d, NULL, AtomSel::on, PickList::pick_check, VMDApp::pickList, Timestep::pos, position, TARGET_GRAB, TARGET_TUG, Displayable::tm, Matrix4::translate, vec_copy, and vec_scale.

Referenced by SpringTool::do_event, TugTool::do_event, RotateTool::do_event, PinchTool::do_event, JoystickTool::do_event, and GrabTool::do_event.

void Tool::tool_location_update   [protected]
 

Trigger callbacks based on current position.

Definition at line 273 of file P_Tool.C.

References UIObject::app, UIObject::make_callbacks, NULL, PickList::pick_check, VMDApp::pickList, and position.

Referenced by SpringTool::do_event, and TugTool::do_event.

void Tool::tug const float *    [protected]
 

Apply the given force to the current target.

Definition at line 387 of file P_Tool.C.

References Molecule::addForce, UIObject::app, DrawMolItem::atomSel, DrawMolecule::component, AtomSel::firstsel, force, AtomSel::lastsel, BaseMolecule::mass, MoleculeList::mol_from_id, VMDApp::moleculeList, VMDApp::molrep_get_by_name, Matrix4::multpoint3d, AtomSel::on, Displayable::rotm, Matrix4::transpose, and vec_scale.

Referenced by PinchTool::do_event.

virtual const char* Tool::type_name   const [pure virtual]
 

return the name of this tool. Must be unique to all Tool subclasses!

Implemented in GrabTool.

Referenced by ToolFltkMenu::reset_tool_list, ToolFltkMenu::select_tool, and text_cmd_tool.

void Tool::ungrab  
 

Definition at line 478 of file P_Tool.C.

References UIObject::app, BaseMolecule::id, id, MoleculeList::molecule, VMDApp::molecule_fix, VMDApp::moleculeList, MoleculeList::num, and Displayable::unfix.


Member Data Documentation

Displayable* Tool::dtool [protected]
 

The visual representation of this tool. It's not private because for some reason the TugTool needs access to some of its members.

Definition at line 164 of file P_Tool.h.

Referenced by check_event, SpringTool::do_event, TugTool::do_event, Tool, and ~Tool.

float Tool::forcescale [protected]
 

scales force sent to the atoms.

Definition at line 106 of file P_Tool.h.

Referenced by SpringTool::do_event, TugTool::do_event, PinchTool::do_event, getforcescale, setforcescale, steal_sensor, and Tool.

int Tool::grabs
 

Definition at line 138 of file P_Tool.h.

float Tool::springscale [protected]
 

scales force sent to the feedback device.

Definition at line 107 of file P_Tool.h.

Referenced by addplaneconstraint, getspringscale, setconstraint, setforcefield, setplaneconstraint, setspringscale, steal_sensor, and Tool.

int Tool::wasgrabbing [protected]
 

XXX Should be private variable; gets set to isgrabbing() by RotateTool.

Definition at line 212 of file P_Tool.h.

Referenced by RotateTool::do_event, GrabTool::do_event, and Tool.


The documentation for this class was generated from the following files:
Generated on Fri Nov 8 02:47:24 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002