| 1 |
#include "createCoords.h" |
| 2 |
|
| 3 |
#include "gplaut04.h" |
| 4 |
#include "axis.h" |
| 5 |
|
| 6 |
static struct coordScaleParameters |
| 7 |
{ |
| 8 |
double csclMax; |
| 9 |
double csclMin; |
| 10 |
int csclNumTicker; |
| 11 |
} cspX, cspY, cspZ; |
| 12 |
|
| 13 |
SoSeparator * createCoordinates(float sclMax[3], float sclMin[3], SbColor color[3]) |
| 14 |
{ |
| 15 |
SoSeparator * aSep = new SoSeparator; |
| 16 |
return aSep; |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
SoSeparator * createCoordinates(bool show3D, int where, float sclMax[3], float sclMin[3], int tickers[3], SbColor color[3]) |
| 21 |
{ |
| 22 |
SoSeparator *axisSep = new SoSeparator; |
| 23 |
|
| 24 |
float transDis = -1.1; |
| 25 |
|
| 26 |
//create Z-axis |
| 27 |
if(show3D) |
| 28 |
{ |
| 29 |
SoSeparator *zSep = new SoSeparator(); |
| 30 |
|
| 31 |
SoTransform *zXform = new SoTransform; |
| 32 |
if(where == COORD_AT_ORIGIN) |
| 33 |
{ |
| 34 |
float x, y; |
| 35 |
x = -1 -sclMin[0] / (sclMax[0] - sclMin[0]) * 2; |
| 36 |
y = -1 -sclMin[1] / (sclMax[1] - sclMin[1]) * 2; |
| 37 |
zXform->translation.setValue(x, 0, -y); |
| 38 |
} |
| 39 |
else if(where == LEFTBACK || where == LEFTAHEAD) |
| 40 |
{ |
| 41 |
zXform->translation.setValue(-1.1, 0.0, -1.1); |
| 42 |
} |
| 43 |
|
| 44 |
cspZ.csclMax = sclMax[2]; |
| 45 |
cspZ.csclMin = sclMin[2]; |
| 46 |
cspZ.csclNumTicker= tickers[2]; |
| 47 |
Axis axisZ = Axis(show3D, where, cspZ.csclMax,cspZ.csclMin,cspZ.csclNumTicker,"Z-Axis/(Z)", 0, color[2]); |
| 48 |
|
| 49 |
zSep->addChild(zXform); |
| 50 |
zSep->addChild(axisZ.createAxis()); |
| 51 |
axisSep->addChild(zSep); |
| 52 |
transDis = -1.1; |
| 53 |
} |
| 54 |
else |
| 55 |
{ |
| 56 |
transDis = 0; |
| 57 |
} |
| 58 |
|
| 59 |
//create X-axis |
| 60 |
SoSeparator *xSep = new SoSeparator(); |
| 61 |
|
| 62 |
SoTransform *xXform = new SoTransform; |
| 63 |
if(where == COORD_AT_ORIGIN) |
| 64 |
{ |
| 65 |
float y, z; |
| 66 |
y = -1 -sclMin[1] / (sclMax[1] - sclMin[1]) * 2; |
| 67 |
z = -1 -sclMin[2] / (sclMax[2] - sclMin[2]) * 2; |
| 68 |
xXform->translation.setValue(0.0, z, -y); |
| 69 |
} |
| 70 |
else if(where == LEFTBACK || where == LEFTAHEAD) |
| 71 |
{ |
| 72 |
if(where==LEFTBACK) |
| 73 |
xXform->translation.setValue(0.0, transDis, -1.1); |
| 74 |
else |
| 75 |
xXform->translation.setValue(-0.0, transDis, 1.1); |
| 76 |
|
| 77 |
} |
| 78 |
xXform->rotation.setValue(SbVec3f(0.0, 0.0, 1.0), -M_PI_2); |
| 79 |
|
| 80 |
cspX.csclMax = sclMax[0]; |
| 81 |
cspX.csclMin = sclMin[0]; |
| 82 |
cspX.csclNumTicker= tickers[0]; |
| 83 |
Axis axisX = Axis(show3D, where, cspX.csclMax,cspX.csclMin,cspX.csclNumTicker,"X-Axis/(X)", 1, color[0]); |
| 84 |
|
| 85 |
xSep->addChild(xXform); |
| 86 |
xSep->addChild(axisX.createAxis()); |
| 87 |
|
| 88 |
//create Y-axis |
| 89 |
SoSeparator *ySep = new SoSeparator(); |
| 90 |
|
| 91 |
SoTransform *yXform = new SoTransform; |
| 92 |
if(where == COORD_AT_ORIGIN) |
| 93 |
{ |
| 94 |
float x, z; |
| 95 |
x = -1 -sclMin[0] / (sclMax[0] - sclMin[0]) * 2; |
| 96 |
z = -1 -sclMin[2] / (sclMax[2] - sclMin[2]) * 2; |
| 97 |
yXform->translation.setValue(x, z, 0.0); |
| 98 |
} |
| 99 |
else if(where == LEFTBACK || where == LEFTAHEAD) |
| 100 |
{ |
| 101 |
yXform->translation.setValue(-1.1, transDis, 0.00); |
| 102 |
} |
| 103 |
|
| 104 |
yXform->rotation.setValue(SbVec3f(1.0, 0.0, 0.0),M_PI_2); |
| 105 |
|
| 106 |
cspY.csclMax = sclMax[1]; |
| 107 |
cspY.csclMin = sclMin[1]; |
| 108 |
cspY.csclNumTicker= tickers[1]; |
| 109 |
Axis axisY = Axis(show3D, where, cspY.csclMax,cspY.csclMin,cspY.csclNumTicker,"Y-Axis/(Y)", -1, color[1]); |
| 110 |
|
| 111 |
ySep->addChild(yXform); |
| 112 |
ySep->addChild(axisY.createAxis()); |
| 113 |
|
| 114 |
axisSep->addChild(xSep); |
| 115 |
axisSep->addChild(ySep); |
| 116 |
|
| 117 |
return axisSep; |
| 118 |
} |