CMS 3D CMS Logo

IgSoPlaneManip Class Reference

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

List of all members.

Public Member Functions

SoDragger * getDragger (void)
void getMotionMatrix (SbMatrix &matrix, bool scaling=true)
 IgSoPlaneManip (void)
virtual void write (SoWriteAction *action)

Static Public Member Functions

static void initClass (void)

Public Attributes

SoSFBool manip
SoSFPlane plane

Protected Member Functions

 ~IgSoPlaneManip (void)

Private Member Functions

bool hasDragger (void)
 SO_NODE_HEADER (IgSoPlaneManip)

Static Private Member Functions

static void jackChanged (void *me, SoDragger *dragger)
static void manipChanged (void *me, SoSensor *sensor)
static void planeChanged (void *me, SoSensor *sensor)

Private Attributes

SoJackDragger * m_manip
SoFieldSensor * m_manipSensor
SoFieldSensor * m_planeSensor


Detailed Description

Definition at line 28 of file IgSoPlaneManip.h.


Constructor & Destructor Documentation

IgSoPlaneManip::IgSoPlaneManip ( void   ) 

Definition at line 25 of file IgSoPlaneManip.cc.

References f, FALSE, jackChanged(), m_manip, m_manipSensor, m_planeSensor, manip, manipChanged(), plane, and planeChanged().

00026     : m_manip (new SoJackDragger),
00027       m_manipSensor (0),
00028       m_planeSensor (0)
00029 {
00030     SO_NODE_CONSTRUCTOR (IgSoPlaneManip);
00031     SO_NODE_ADD_FIELD   (plane,    (SbPlane (SbVec3f (0.0f, 1.0f, 0.0f), 0.0f)));
00032     SO_NODE_ADD_FIELD   (manip,  (FALSE));
00033  
00034     m_manip->ref();
00035     m_manip->addValueChangedCallback(jackChanged, this);
00036     
00037     m_manipSensor = new SoFieldSensor (&manipChanged, this);
00038     m_manipSensor->attach (&manip);
00039     
00040     m_planeSensor = new SoFieldSensor (&planeChanged, this);
00041 }

IgSoPlaneManip::~IgSoPlaneManip ( void   )  [protected]

Definition at line 43 of file IgSoPlaneManip.cc.

References m_manip, m_manipSensor, and m_planeSensor.

00044 {
00045     m_manip->unref();
00046     delete m_manipSensor;
00047     delete m_planeSensor;
00048 }


Member Function Documentation

SoDragger * IgSoPlaneManip::getDragger ( void   ) 

Definition at line 51 of file IgSoPlaneManip.cc.

References m_manip.

00052 { return m_manip; }

void IgSoPlaneManip::getMotionMatrix ( SbMatrix &  matrix,
bool  scaling = true 
)

Definition at line 55 of file IgSoPlaneManip.cc.

References f, m_manip, plane, r, s, and t.

Referenced by IgSoFieldPlane::updateCorners().

00056 {
00057     matrix = m_manip->getMotionMatrix();
00058       
00059     SbVec3f normal = plane.getValue().getNormal();
00060     SbVec3f t, s;
00061     SbRotation r, so;      
00062     matrix.getTransform(t, r, s, so);
00063     r.setValue(SbVec3f(0.0f, 1.0f, 0.0f), normal);
00064     t = normal * plane.getValue().getDistanceFromOrigin ();
00065     if (scaling)
00066         s.setValue (1.0f, 1.0f, 1.0f);
00067     matrix.setTransform(t, r, s, so);
00068 }

bool IgSoPlaneManip::hasDragger ( void   )  [private]

Definition at line 129 of file IgSoPlaneManip.cc.

00130 {
00131     return (getNumChildren () > 0) &&
00132          dynamic_cast<SoJackDragger*>(getChild(0));
00133 }

void IgSoPlaneManip::initClass ( void   )  [static]

Definition at line 20 of file IgSoPlaneManip.cc.

Referenced by initNodes(), and initShapes().

00021 {
00022     SO_NODE_INIT_CLASS (IgSoPlaneManip, SoNode, "Node");
00023 }

void IgSoPlaneManip::jackChanged ( void me,
SoDragger *  dragger 
) [static, private]

Definition at line 71 of file IgSoPlaneManip.cc.

References f, matrix, and plane.

Referenced by IgSoPlaneManip().

00072 {
00073     IgSoPlaneManip * self = static_cast<IgSoPlaneManip*>(me);
00074     SbMatrix matrix = dragger->getMotionMatrix();
00075 
00076     SbPlane plane(SbVec3f(0.0f, 1.0f, 0.0f), 0.0f);
00077     plane.transform(matrix);
00078     
00079     if ((plane.getNormal().equals (self->plane.getValue().getNormal(), 0.01f)) &&
00080         (fabs(plane.getDistanceFromOrigin() - 
00081               self->plane.getValue().getDistanceFromOrigin()) < 0.0001))
00082         return;
00083 
00084     if (self->manip.getValue ())
00085     {
00086         self->m_planeSensor->detach();
00087         self->plane = plane;
00088         self->m_planeSensor->attach(&self->plane);
00089     }
00090     else
00091         self->plane = plane;
00092 }

void IgSoPlaneManip::manipChanged ( void me,
SoSensor *  sensor 
) [static, private]

Definition at line 108 of file IgSoPlaneManip.cc.

Referenced by IgSoPlaneManip().

00109 {
00110     IgSoPlaneManip * self = static_cast<IgSoPlaneManip*>(me);
00111     if (self->manip.getValue ())
00112     {
00113         if (!self->hasDragger ())
00114         {
00115             self->insertChild (self->m_manip, 0);
00116             self->m_planeSensor->attach (&self->plane);
00117             self->m_planeSensor->trigger ();
00118         }
00119     }
00120     else if(self->hasDragger ())
00121     {
00122         self->m_planeSensor->detach ();
00123         self->m_manip->enableValueChangedCallbacks(false);
00124         self->removeChild (self->m_manip);
00125     }
00126 }

void IgSoPlaneManip::planeChanged ( void me,
SoSensor *  sensor 
) [static, private]

Definition at line 95 of file IgSoPlaneManip.cc.

References matrix.

Referenced by IgSoPlaneManip().

00096 {
00097     IgSoPlaneManip * self = static_cast<IgSoPlaneManip*>(me);
00098     
00099     SbMatrix matrix;
00100     self->getMotionMatrix (matrix, false);
00101       
00102     self->m_manip->enableValueChangedCallbacks(false);
00103     self->m_manip->setMotionMatrix(matrix);
00104     self->m_manip->enableValueChangedCallbacks(true);
00105 }

IgSoPlaneManip::SO_NODE_HEADER ( IgSoPlaneManip   )  [private]

void IgSoPlaneManip::write ( SoWriteAction *  action  )  [virtual]

Definition at line 136 of file IgSoPlaneManip.cc.

00137 { SoNode::write (action); }


Member Data Documentation

SoJackDragger* IgSoPlaneManip::m_manip [private]

Definition at line 54 of file IgSoPlaneManip.h.

Referenced by getDragger(), getMotionMatrix(), IgSoPlaneManip(), and ~IgSoPlaneManip().

SoFieldSensor* IgSoPlaneManip::m_manipSensor [private]

Definition at line 55 of file IgSoPlaneManip.h.

Referenced by IgSoPlaneManip(), and ~IgSoPlaneManip().

SoFieldSensor* IgSoPlaneManip::m_planeSensor [private]

Definition at line 56 of file IgSoPlaneManip.h.

Referenced by IgSoPlaneManip(), and ~IgSoPlaneManip().

SoSFBool IgSoPlaneManip::manip

Definition at line 34 of file IgSoPlaneManip.h.

Referenced by IgSoFieldPlane::buildStructure(), IgSoFieldPlane::field(), IgSoPlaneManip(), and IgSoSlicer::IgSoSlicer().

SoSFPlane IgSoPlaneManip::plane

Definition at line 33 of file IgSoPlaneManip.h.

Referenced by IgSoFieldPlane::attachSensors(), getMotionMatrix(), IgSoPlaneManip(), IgSoSlicer::IgSoSlicer(), and jackChanged().


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