00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00044 float GeometryAngle::calculate(void) {
00045
00046
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
00062 void GeometryAngle::create_cmd_list() {
00063 char valbuf[32];
00064
00065
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
00084 display_line(pos1, pos2, cmdList);
00085 display_line(pos2, pos3, cmdList);
00086
00087
00088 midpoint(valuePos, pos1, pos3);
00089 midpoint(valuePos, valuePos, pos2);
00090
00091
00092
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
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