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

PickModeUser.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: PickModeUser.C,v $
00013  *      $Author: johns $        $Locker:  $                $State: Exp $
00014  *      $Revision: 1.8 $      $Date: 2019/01/17 21:21:01 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * The PickMode object which allows a pointer to be used to make selections
00020  * that interact with user-defined scripts and plugins.  No labels are added.
00021  *
00022  ***************************************************************************/
00023 
00024 #include <math.h>
00025 #include "PickModeUser.h"
00026 #include "Pickable.h"
00027 #include "DisplayDevice.h"
00028 #include "Inform.h"
00029 #include "DrawMolecule.h"
00030 #include "CommandQueue.h"
00031 #include "TextEvent.h"
00032 #include "VMDApp.h"
00033 #include "utilities.h"
00034 
00035 PickModeUser::PickModeUser(VMDApp *vmdapp) 
00036 : app(vmdapp) {
00037   needName = FALSE;
00038 
00039   // indicate we're still at the starting trying to find something
00040   haveItems = 0;
00041 }
00042 
00043 void PickModeUser::pick_molecule_start(DrawMolecule *mol, DisplayDevice *d,
00044                         int, int tag, const int * /* cell */ , int dim, const float *pos) {
00045   // ignore the cell argument; we don't create bonds between images!
00046   atom = tag;
00047   memcpy(pPos, pos, dim*sizeof(float));
00048   needName = TRUE;
00049   
00050   int shift_pressed = d->shift_state() & DisplayDevice::SHIFT;
00051   app->commandQueue->runcommand(new PickAtomEvent(mol->id(), tag, 
00052     shift_pressed, true));
00053 }
00054 
00055 void PickModeUser::pick_molecule_end(DrawMolecule *m, DisplayDevice *) {
00056 
00057   if(needName) {
00058     // the selection was successful; first save the info for the object
00059 
00060     int id = m->id();
00061     molid = id; 
00062     atmid = atom;
00063 
00064     // indicate we have one more items in the ones we need
00065     haveItems++;
00066 
00067     // now check if we have enough items for the object we're out for
00068     if(haveItems >= 1) {
00069       msgInfo << "User Pick: mol" << molid << " atom:" << atmid << sendmsg;
00070       // indicate we're done with this selection
00071       haveItems = 0;
00072     } 
00073   }
00074   needName = FALSE;
00075 }
00076 

Generated on Sat Oct 12 02:44:56 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002