CMS 3D CMS Logo

IgSoAxis Class Reference

Provides a co-ordinate axis shape with label and adjustable length markers. More...

#include <Iguana/Inventor/interface/IgSoAxis.h>

Inheritance diagram for IgSoAxis:

IgSoShapeKit

List of all members.

Public Member Functions

 IgSoAxis (void)

Static Public Member Functions

static void initClass (void)

Public Attributes

SoSFFloat divisionLength
SoSFInt32 divisions
SoSFString label
SoSFBool offset
SoSFFloat totalLength

Protected Member Functions

virtual void refresh (void)

Private Member Functions

 SO_KIT_CATALOG_ENTRY_HEADER (labelText)
 SO_KIT_CATALOG_ENTRY_HEADER (labelTrans)
 SO_KIT_CATALOG_ENTRY_HEADER (labelSep)
 SO_KIT_CATALOG_ENTRY_HEADER (font)
 SO_KIT_CATALOG_ENTRY_HEADER (markers)
 SO_KIT_CATALOG_ENTRY_HEADER (headCone)
 SO_KIT_CATALOG_ENTRY_HEADER (headTrans)
 SO_KIT_CATALOG_ENTRY_HEADER (head)
 SO_KIT_CATALOG_ENTRY_HEADER (line)
 SO_KIT_HEADER (IgSoAxis)


Detailed Description

Provides a co-ordinate axis shape with label and adjustable length markers.

Definition at line 27 of file IgSoAxis.h.


Constructor & Destructor Documentation

IgSoAxis::IgSoAxis ( void   ) 

Definition at line 32 of file IgSoAxis.cc.

References divisionLength, divisions, FALSE, label, parsecf::pyparsing::line(), offset, IgSoShapeKit::setUpConnections(), totalLength, and TRUE.

00033 {
00034     SO_KIT_CONSTRUCTOR (IgSoAxis);
00035     SO_KIT_ADD_FIELD (divisions,      (3));
00036     SO_KIT_ADD_FIELD (divisionLength, (0.5));
00037     SO_KIT_ADD_FIELD (label,          ("Z"));
00038     SO_KIT_ADD_FIELD (totalLength,    (2.0));
00039     SO_KIT_ADD_FIELD (offset,         (false));
00040 
00041     SO_KIT_ADD_CATALOG_ENTRY (line,  SoLineSet, FALSE, separator,\x0, TRUE);
00042     SO_KIT_ADD_CATALOG_ENTRY (head, SoSeparator, FALSE, separator,\x0, TRUE);
00043     SO_KIT_ADD_CATALOG_ENTRY (headTrans, SoTransform, FALSE, head,\x0, TRUE);
00044     SO_KIT_ADD_CATALOG_ENTRY (headCone, SoCone, FALSE, head,\x0, TRUE);
00045     SO_KIT_ADD_CATALOG_ENTRY (markers, SoSeparator, FALSE, separator,\x0, TRUE);
00046     SO_KIT_ADD_CATALOG_ENTRY (font, SoFont, FALSE, separator,\x0, TRUE);
00047     SO_KIT_ADD_CATALOG_ENTRY (labelSep, SoSeparator, FALSE, separator,\x0, TRUE);
00048     SO_KIT_ADD_CATALOG_ENTRY (labelTrans, SoTranslation, FALSE, labelSep,\x0, TRUE);
00049     SO_KIT_ADD_CATALOG_ENTRY (labelText, SoText2, FALSE, labelSep,\x0, TRUE);
00050 
00051     SO_KIT_INIT_INSTANCE ();
00052     setUpConnections (true, true);
00053 }


Member Function Documentation

void IgSoAxis::initClass ( void   )  [static]

Reimplemented from IgSoShapeKit.

Definition at line 29 of file IgSoAxis.cc.

Referenced by initNodes(), and initShapes().

00030 { SO_KIT_INIT_CLASS (IgSoAxis,IgSoShapeKit,"IgSoShapeKit"); }

void IgSoAxis::refresh ( void   )  [protected, virtual]

Reimplemented from IgSoShapeKit.

Definition at line 56 of file IgSoAxis.cc.

References divisionLength, divisions, label, parsecf::pyparsing::line(), offset, and totalLength.

00057 {
00058     
00059     float axisLength ;
00060     axisLength = (offset.getValue ()) ? (totalLength.getValue ()): (divisionLength.getValue () * divisions.getValue ());   
00061         
00062 
00063     SoVertexProperty    *vtx = new SoVertexProperty;
00064     SoLineSet           *line = new  SoLineSet;
00065     SoTransform         *headTrans = new SoTransform;
00066     SoCone              *headCone = new SoCone;
00067     SoSeparator         *markers = new SoSeparator;
00068     SoFont              *font = new SoFont;
00069     SoTranslation       *labelTrans = new SoTranslation;
00070     SoText2             *labelText = new SoText2;
00071 
00072     // Make the axis line
00073     vtx->vertex.set1Value (0, SbVec3f (0, 0, 0));
00074     vtx->vertex.set1Value (1, SbVec3f (0, 0, axisLength));
00075     line->startIndex = 0;
00076     line->numVertices = 2;
00077     line->vertexProperty = vtx;
00078 
00079     // Make arrowhead for the end of the line
00080     float coneHeight; //, coneRadius;
00081 
00082     if (offset.getValue ()) 
00083     {
00084         // if total length is smaller than 2.0 then scale the arrow head according to length
00085         // else assign a fixed value to the cone height
00086         coneHeight = (axisLength >= 2.0) ? 0.25: axisLength / 8.0;      
00087     }
00088     else
00089     {
00090         coneHeight = axisLength / 8.0;
00091     }
00092    
00093     headCone->bottomRadius = divisionLength.getValue () / 10;
00094     headCone->height = coneHeight;
00095     if (offset.getValue ()) 
00096     {
00097         headTrans->translation.setValue (0, 0, axisLength - coneHeight / 2);
00098     }
00099     else
00100     {
00101         headTrans->translation.setValue (0, 0, axisLength + coneHeight / 2);
00102     }
00103     
00104     headTrans->rotation.setValue (SbVec3f (1, 0, 0), M_PI / 2);
00105 
00106     // Make division markers
00107     SoRotation *markerRot = new SoRotation;
00108     markerRot->rotation.setValue (SbVec3f (1, 0, 0), M_PI / 2);
00109     markers->addChild (markerRot);
00110 
00111     long divs = divisions.getValue () - 1;
00112     if (divs >= 1)
00113     {
00114         SoCylinder *marker = new SoCylinder;
00115         marker->radius.setValue (divisionLength.getValue () / 10);
00116         marker->height.setValue (axisLength / 200);
00117 
00118         for (int div = 0; div < divs ; div++)
00119         {
00120             SoTranslation *offset = new SoTranslation;  
00121             offset->translation.setValue (0, divisionLength.getValue (), 0);
00122             markers->addChild (offset);
00123             markers->addChild (marker);
00124         }
00125     }
00126 
00127     // Put letter at the ends of the axes
00128     font->size.setValue (16.0);
00129     font->name.setValue ("Times-Roman");
00130     labelTrans->translation.setValue (0, 0, 1.05 * (axisLength + coneHeight));
00131     labelText->string = label.getValue ();
00132     labelText->justification = SoText2::CENTER;
00133 
00134     setPart ("line",            line);
00135     setPart ("headTrans",       headTrans);
00136     setPart ("headCone",        headCone);
00137     setPart ("markers",         markers);
00138     setPart ("font",            font);
00139     setPart ("labelTrans",      labelTrans);
00140     setPart ("labelText",       labelText);
00141 }

IgSoAxis::SO_KIT_CATALOG_ENTRY_HEADER ( labelText   )  [private]

IgSoAxis::SO_KIT_CATALOG_ENTRY_HEADER ( labelTrans   )  [private]

IgSoAxis::SO_KIT_CATALOG_ENTRY_HEADER ( labelSep   )  [private]

IgSoAxis::SO_KIT_CATALOG_ENTRY_HEADER ( font   )  [private]

IgSoAxis::SO_KIT_CATALOG_ENTRY_HEADER ( markers   )  [private]

IgSoAxis::SO_KIT_CATALOG_ENTRY_HEADER ( headCone   )  [private]

IgSoAxis::SO_KIT_CATALOG_ENTRY_HEADER ( headTrans   )  [private]

IgSoAxis::SO_KIT_CATALOG_ENTRY_HEADER ( head   )  [private]

IgSoAxis::SO_KIT_CATALOG_ENTRY_HEADER ( line   )  [private]

IgSoAxis::SO_KIT_HEADER ( IgSoAxis   )  [private]


Member Data Documentation

SoSFFloat IgSoAxis::divisionLength

Definition at line 45 of file IgSoAxis.h.

Referenced by IgSoAxis(), IgSoCoordinateAxis::refresh(), and refresh().

SoSFInt32 IgSoAxis::divisions

Definition at line 44 of file IgSoAxis.h.

Referenced by IgSoAxis(), IgSoCoordinateAxis::refresh(), and refresh().

SoSFString IgSoAxis::label

Definition at line 46 of file IgSoAxis.h.

Referenced by IgSoAxis(), IgSoCoordinateAxis::refresh(), and refresh().

SoSFBool IgSoAxis::offset

Definition at line 48 of file IgSoAxis.h.

Referenced by IgSoAxis(), and refresh().

SoSFFloat IgSoAxis::totalLength

Definition at line 47 of file IgSoAxis.h.

Referenced by IgSoAxis(), and refresh().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:25:39 2009 for CMSSW by  doxygen 1.5.4