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

PickModeCenter.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: PickModeCenter.C,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.33 $       $Date: 2019/01/17 21:21:01 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *   Pick on an atom to change the molecule's centering/global matricies
00019  ***************************************************************************/
00020 
00021 #include <math.h>
00022 #include <string.h>
00023 #include "PickModeCenter.h"
00024 #include "Pickable.h"
00025 #include "VMDApp.h"
00026 #include "MoleculeList.h"
00027 
00028 PickModeCenter::PickModeCenter(VMDApp *vmdapp) : app(vmdapp) {}
00029 
00030 void PickModeCenter::pick_molecule_start(DrawMolecule *, DisplayDevice *,
00031                int, int tag, const int * cell, int dim, const float *pos) {
00032   pAtom = tag;
00033   memcpy(pPos, pos, dim*sizeof(float));
00034   memcpy(pCell, cell, 3L*sizeof(int));
00035   needName = TRUE; 
00036 }
00037 
00038 void PickModeCenter::pick_molecule_move(DrawMolecule *, DisplayDevice *,
00039                                         int, int dim, const float *pos) {
00040   if(needName) {
00041     float mvdist = 0.0;
00042     for(int i=0; i < dim; i++)
00043       mvdist += (float) fabs(pPos[i] - pos[i]);
00044     if(mvdist > 0.02 )
00045       needName = FALSE;
00046   }
00047 }
00048 
00049 void PickModeCenter::pick_molecule_end(DrawMolecule *mol, DisplayDevice *) {
00050   if (!needName) return;
00051 
00052   const Timestep *ts = mol->current();
00053   const float *coord = ts->pos + pAtom * 3L;
00054   float tcoord[3]; // transformed coordinate
00055   Matrix4 mat;
00056   ts->get_transform_from_cell(pCell, mat);
00057   mat.multpoint3d(coord, tcoord);
00058 
00059   // and apply the result to all the active molecules
00060   // XXX There should be a high-level command for this.
00061   DrawMolecule *m;
00062   for (int m_id = 0; m_id < app->moleculeList->num(); m_id++) {
00063     m = app->moleculeList->molecule(m_id);
00064     if (m->active) {
00065       m->change_center(tcoord[0], tcoord[1], tcoord[2]);
00066     }
00067   }
00068 }
00069 

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