00001
00002
00003 #include "Iguana/Inventor/interface/IgSo2DArrow.h"
00004 #include <Inventor/nodes/SoVertexProperty.h>
00005 #include <Inventor/nodes/SoLineSet.h>
00006 #include <Inventor/nodes/SoFaceSet.h>
00007
00008
00009
00010
00011
00012
00013
00014
00015 SO_KIT_SOURCE (IgSo2DArrow);
00016
00017
00018
00019
00020
00021 void
00022 IgSo2DArrow::initClass (void)
00023 { SO_KIT_INIT_CLASS (IgSo2DArrow, IgSoShapeKit, "IgSoShapeKit"); }
00024
00025 IgSo2DArrow::IgSo2DArrow (void)
00026 {
00027 SO_KIT_CONSTRUCTOR (IgSo2DArrow);
00028 SO_KIT_ADD_FIELD (length, (1.0f));
00029 SO_KIT_ADD_FIELD (lengthRatio, (0.1f));
00030 SO_KIT_ADD_FIELD (headHeight, (0.05f));
00031 SO_KIT_ADD_CATALOG_ENTRY (line, SoLineSet, FALSE, separator,\x0, TRUE);
00032 SO_KIT_ADD_CATALOG_ENTRY (head, SoFaceSet, FALSE, separator,\x0, TRUE);
00033 SO_KIT_INIT_INSTANCE ();
00034 setUpConnections (true, true);
00035 }
00036
00037 void
00038 IgSo2DArrow::refresh (void)
00039 {
00040 SoLineSet *line = new SoLineSet;
00041 SoFaceSet *head = new SoFaceSet;
00042 SoVertexProperty *vtx;
00043
00044 float lRatio = lengthRatio.getValue ();
00045 float hh = headHeight.getValue ();
00046 float l = length.getValue ();
00047
00048
00049 vtx = new SoVertexProperty;
00050 vtx->vertex.set1Value (0, 0.f, 0.f, 0.f);
00051 vtx->vertex.set1Value (1, (1.f-lRatio)*l, 0.f, 0.f);
00052 vtx->normal = SbVec3f (0.f,0.f,1.f);
00053 line->numVertices = 2;
00054 line->vertexProperty = vtx;
00055
00056
00057 vtx = new SoVertexProperty;
00058 vtx->vertex.set1Value (0, (1.f-lRatio)*l, -.5f*hh, 0.f);
00059 vtx->vertex.set1Value (1, l, 0.f, 0.f);
00060 vtx->vertex.set1Value (2, (1.f-lRatio)*l, .5f*hh, 0.f);
00061 vtx->normal = SbVec3f (0.f,0.f,1.f);
00062 head->numVertices = 3;
00063 head->vertexProperty = vtx;
00064
00065 setPart ("line", line);
00066 setPart ("head", head);
00067 }