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

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

Generated on Thu Apr 25 02:42:39 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002