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

GeometryBond.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: GeometryBond.C,v $
00013  *      $Author: johns $        $Locker:  $                $State: Exp $
00014  *      $Revision: 1.28 $      $Date: 2019/01/17 21:20:59 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *
00019  * Measures the angle between two atoms, and draws a marker for the bond
00020  * into the display list for a given Displayable.
00021  *
00022  ***************************************************************************/
00023 
00024 #include <stdio.h>
00025 
00026 #include "GeometryBond.h"
00027 #include "MoleculeList.h"
00028 #include "Molecule.h"
00029 #include "utilities.h"
00030 
00031 
00033 GeometryBond::GeometryBond(int *m, int *a, const int *cell, MoleculeList *mlist,
00034     CommandQueue *cq, Displayable *d)
00035         : GeometryMol(2, m, a, cell, mlist, cq, d) { }
00036 
00037 // recalculate the value of this geometry, and return it
00038 float GeometryBond::calculate(void) {
00039 
00040   // get coords to calculate distance 
00041   float pos1[3], pos2[3];
00042   if(!normal_atom_coord(0, pos1))
00043     return 0.0;
00044   if(!normal_atom_coord(1, pos2))
00045     return 0.0;
00046 
00047   vec_sub(pos2, pos2, pos1);
00048   return(geomValue = norm(pos2));
00049 }
00050 
00051 
00052 // draw the geometry marker in the given Displayable's drawing list
00053 void GeometryBond::create_cmd_list() {
00054   char valbuf[32];
00055 
00056   // get the transformed positions, and draw a line between them
00057   float pos1[3], pos2[3];
00058 
00059   reset_disp_list();
00060   if(!transformed_atom_coord(0, pos1))
00061     return;
00062   if(!transformed_atom_coord(1, pos2))
00063     return;
00064 
00065   append(DMATERIALOFF);
00066   DispCmdColorIndex cmdColor;
00067   cmdColor.putdata(my_color, cmdList);
00068 
00069   DispCmdLineType cmdLineType;
00070   DispCmdLineWidth cmdLineWidth;
00071   cmdLineType.putdata(DASHEDLINE, cmdList);
00072   cmdLineWidth.putdata(4, cmdList);
00073 
00074   // print value of distance at midpoint
00075   midpoint(valuePos, pos1, pos2);
00076   // left-align the value so that it doesn't appear to shift its position
00077   // when the label text size changes.  Shift it to the right by a constant
00078   // amount so that it doesn't intersect the line.
00079   valuePos[0] += 0.05f;
00080   sprintf(valbuf, "%-7.2f", geomValue);
00081   display_string(valbuf, cmdList);
00082 
00083   // draw a line into the given Displayable
00084   display_line(pos1, pos2, cmdList);
00085   
00086 }
00087 
00088 void GeometryBond::set_pick(void) {
00089 
00090   // set the Tcl values
00091   if(objIndex[0] == objIndex[1]) {  // selections must be from the same molid
00092     set_pick_selection(objIndex[0], 2, comIndex);
00093   } else {
00094     set_pick_selection();  // if bad, set to the "nothing" molecule
00095   }
00096   set_pick_value(geomValue);
00097 }
00098 

Generated on Fri Oct 11 02:43:45 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002