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

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

Generated on Tue Nov 18 02:47:09 2025 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002

AltStyle によって変換されたページ (->オリジナル) /