#include <Iguana/Inventor/interface/IgSoAnimator.h>
Public Member Functions | |
IgSoAnimator (void) | |
virtual void | write (SoWriteAction *action) |
Static Public Member Functions | |
static void | initClass (void) |
Public Attributes | |
SoSFVec3f | axis |
SoSFBool | complete |
SoSFInt32 | newAxis |
SoSFBool | on |
SoSFBool | reset |
SoSFInt32 | state |
SoSFFloat | timeFreq |
SoSFShort | timeMax |
SoSFShort | timeStep |
Protected Member Functions | |
~IgSoAnimator () | |
Private Member Functions | |
void | initAnim (void) |
SO_NODE_HEADER (IgSoAnimator) | |
void | updateAxis (void) |
Static Private Member Functions | |
static void | invokeUpdateAxis (void *data, SoSensor *sensor) |
static void | onSensorCB (void *me, SoSensor *data) |
static void | resetSensorCB (void *me, SoSensor *data) |
Private Attributes | |
SoCalculator * | m_calc |
SoTimeCounter * | m_counter |
SoComposeRotation * | m_crot |
SoFieldSensor * | m_onSensor |
SoFieldSensor * | m_resetSensor |
SoCounter * | m_stateCounter |
SoFieldSensor * | m_stateSensor |
Definition at line 35 of file IgSoAnimator.h.
IgSoAnimator::IgSoAnimator | ( | void | ) |
Definition at line 29 of file IgSoAnimator.cc.
References axis, complete, FALSE, initAnim(), invokeUpdateAxis(), m_onSensor, m_resetSensor, m_stateSensor, newAxis, on, onSensorCB(), reset, resetSensorCB(), state, timeFreq, timeMax, and timeStep.
00030 : m_crot (0), 00031 m_calc (0), 00032 m_counter (0), 00033 m_stateCounter (0), 00034 m_onSensor (0), 00035 m_resetSensor (0), 00036 m_stateSensor (0) 00037 { 00038 SO_NODE_CONSTRUCTOR (IgSoAnimator); 00039 SO_NODE_ADD_FIELD (timeMax, (2000)); // short int ==> mrad / M_PI 00040 SO_NODE_ADD_FIELD (timeStep, (10)); 00041 SO_NODE_ADD_FIELD (timeFreq, (.05)); 00042 SO_NODE_ADD_FIELD (axis, (SbVec3f (1, 0, 0))); 00043 SO_NODE_ADD_FIELD (on, (FALSE)); 00044 SO_NODE_ADD_FIELD (reset, (FALSE)); 00045 SO_NODE_ADD_FIELD (state, (0)); 00046 SO_NODE_ADD_FIELD (newAxis, (0)); // output signal 00047 SO_NODE_ADD_FIELD (complete, (FALSE)); // output signal 00048 00049 m_stateSensor = new SoFieldSensor (&invokeUpdateAxis, this); 00050 m_stateSensor->setPriority (SoFieldSensor::getDefaultPriority () - 2); 00051 m_onSensor = new SoFieldSensor (&onSensorCB, this); 00052 m_resetSensor = new SoFieldSensor (&resetSensorCB, this); 00053 00054 initAnim (); 00055 }
IgSoAnimator::~IgSoAnimator | ( | ) | [protected] |
Definition at line 57 of file IgSoAnimator.cc.
References m_calc, m_counter, m_crot, m_onSensor, m_resetSensor, m_stateCounter, and m_stateSensor.
00058 { 00059 m_crot->unref (); 00060 m_counter->unref (); 00061 m_calc->unref(); 00062 m_stateCounter->unref(); 00063 delete m_onSensor; 00064 delete m_resetSensor; 00065 delete m_stateSensor; 00066 }
Definition at line 117 of file IgSoAnimator.cc.
References axis, m_calc, m_counter, m_crot, m_onSensor, m_resetSensor, m_stateCounter, m_stateSensor, on, reset, state, timeFreq, timeMax, and timeStep.
Referenced by IgSoAnimator().
00118 { 00119 m_crot = new SoComposeRotation; 00120 m_counter = new SoTimeCounter; 00121 m_calc = new SoCalculator; 00122 m_stateCounter = new SoCounter; 00123 00124 m_counter->ref (); 00125 m_counter->min = 0; 00126 m_counter->max.connectFrom (&timeMax); 00127 m_counter->step.connectFrom (&timeStep); 00128 m_counter->frequency.connectFrom (&timeFreq); 00129 m_counter->on.connectFrom (&on); 00130 00131 // Create a calculator to turn the timer into output angle 00132 m_calc->ref(); 00133 m_calc->a.connectFrom (&m_counter->output); 00134 m_calc->expression.set1Value (0, "oa = M_PI * a / 1000"); // mrad => rad 00135 00136 // Connect the rotation angle into the rotation 00137 m_crot->ref (); 00138 m_crot->axis.connectFrom (&axis); 00139 m_crot->angle.connectFrom (&m_calc->oa); 00140 rotation.connectFrom (&m_crot->rotation); 00141 00142 // Use the state counter to cycle over axes. The states are: 0=X, 1=Y, 2=Z 00143 m_stateCounter->ref (); 00144 m_stateCounter->min = 0; 00145 m_stateCounter->max = 2; 00146 m_stateCounter->step = 1; 00147 m_stateCounter->trigger.connectFrom (&m_counter->syncOut); 00148 m_stateCounter->reset.setValue (0); 00149 00150 // Connect the timer cycle to the state, then connect the state output 00151 // to the callback sensor. Thus when the state changes we get called 00152 // so that we can change the axis. 00153 state.connectFrom (&m_stateCounter->output); 00154 m_stateSensor->attach (&state); 00155 m_onSensor->attach (&on); 00156 m_resetSensor->attach (&reset); 00157 }
Definition at line 24 of file IgSoAnimator.cc.
Referenced by initNodes(), and initShapes().
00025 { 00026 SO_NODE_INIT_CLASS (IgSoAnimator, SoRotation, "Node"); 00027 }
Definition at line 84 of file IgSoAnimator.cc.
References updateAxis().
Referenced by IgSoAnimator().
00085 { static_cast<IgSoAnimator *> (data)->updateAxis (); }
Definition at line 160 of file IgSoAnimator.cc.
Referenced by IgSoAnimator().
00161 { 00162 IgSoAnimator *self = static_cast<IgSoAnimator *> (me); 00163 if (self->on.getValue ()) 00164 self->reset.setValue (false); 00165 }
Definition at line 88 of file IgSoAnimator.cc.
References max, and cmsRelvalreportInput::step.
Referenced by IgSoAnimator().
00089 { 00090 IgSoAnimator *self = static_cast<IgSoAnimator *> (me); 00091 if (self->reset.getValue ()) 00092 { 00093 self->m_stateSensor->detach (); 00094 self->m_onSensor->detach (); 00095 self->m_resetSensor->detach (); 00096 if (self->m_counter->getRefCount()) 00097 { 00098 self->m_stateCounter->unref(); 00099 self->m_crot->unref (); 00100 self->m_calc->unref(); 00101 self->m_counter->unref (); 00102 } 00103 00104 short max = self->timeMax.getValue(); 00105 short step = self->timeStep.getValue(); 00106 float freq = self->timeFreq.getValue(); 00107 self->setToDefaults (); 00108 self->reset = true; 00109 self->timeMax = max; 00110 self->timeStep = step; 00111 self->timeFreq = freq; 00112 self->initAnim (); 00113 } 00114 }
IgSoAnimator::SO_NODE_HEADER | ( | IgSoAnimator | ) | [private] |
Definition at line 69 of file IgSoAnimator.cc.
References axis, complete, newAxis, and state.
Referenced by invokeUpdateAxis().
00070 { 00071 if (state.getValue () == 1) // Rotate about Y 00072 axis.setValue (0, 1, 0); 00073 else if (state.getValue () == 2) // Rotate about Z 00074 axis.setValue (0, 0, 1); 00075 else // Rotate about X 00076 axis.setValue (1, 0, 0); 00077 00078 newAxis = state.getValue (); 00079 if (state.getValue () == 0) 00080 complete = true; 00081 }
void IgSoAnimator::write | ( | SoWriteAction * | action | ) | [virtual] |
Definition at line 168 of file IgSoAnimator.cc.
References m_crot, m_stateCounter, and state.
00169 { 00170 rotation.disconnect (); 00171 state.disconnect (); 00172 SoNode::write (action); 00173 rotation.connectFrom (&m_crot->rotation); 00174 state.connectFrom (&m_stateCounter->output); 00175 }
SoSFVec3f IgSoAnimator::axis |
Definition at line 42 of file IgSoAnimator.h.
Referenced by Ig3DAnimsCategory::attach(), IgSoAnimator(), initAnim(), and updateAxis().
SoSFBool IgSoAnimator::complete |
Definition at line 47 of file IgSoAnimator.h.
Referenced by Ig3DAnimsCategory::attach(), IgSoAnimator(), and updateAxis().
SoCalculator* IgSoAnimator::m_calc [private] |
SoTimeCounter* IgSoAnimator::m_counter [private] |
SoComposeRotation* IgSoAnimator::m_crot [private] |
Definition at line 65 of file IgSoAnimator.h.
Referenced by initAnim(), write(), and ~IgSoAnimator().
SoFieldSensor* IgSoAnimator::m_onSensor [private] |
Definition at line 69 of file IgSoAnimator.h.
Referenced by IgSoAnimator(), initAnim(), and ~IgSoAnimator().
SoFieldSensor* IgSoAnimator::m_resetSensor [private] |
Definition at line 70 of file IgSoAnimator.h.
Referenced by IgSoAnimator(), initAnim(), and ~IgSoAnimator().
SoCounter* IgSoAnimator::m_stateCounter [private] |
Definition at line 68 of file IgSoAnimator.h.
Referenced by initAnim(), write(), and ~IgSoAnimator().
SoFieldSensor* IgSoAnimator::m_stateSensor [private] |
Definition at line 71 of file IgSoAnimator.h.
Referenced by IgSoAnimator(), initAnim(), and ~IgSoAnimator().
SoSFInt32 IgSoAnimator::newAxis |
Definition at line 46 of file IgSoAnimator.h.
Referenced by Ig3DAnimsCategory::attach(), IgSoAnimator(), and updateAxis().
SoSFBool IgSoAnimator::on |
Definition at line 43 of file IgSoAnimator.h.
Referenced by Ig3DAnimsCategory::attach(), IgSoAnimator(), and initAnim().
SoSFBool IgSoAnimator::reset |
Definition at line 44 of file IgSoAnimator.h.
Referenced by Ig3DAnimsCategory::attach(), IgSoAnimator(), and initAnim().
SoSFInt32 IgSoAnimator::state |
Definition at line 45 of file IgSoAnimator.h.
Referenced by Ig3DAnimsCategory::attach(), IgSoAnimator(), initAnim(), updateAxis(), and write().
SoSFFloat IgSoAnimator::timeFreq |
Definition at line 41 of file IgSoAnimator.h.
Referenced by Ig3DAnimsCategory::attach(), IgSoAnimator(), and initAnim().
SoSFShort IgSoAnimator::timeMax |
Definition at line 39 of file IgSoAnimator.h.
Referenced by Ig3DAnimsCategory::attach(), IgSoAnimator(), and initAnim().
SoSFShort IgSoAnimator::timeStep |
Definition at line 40 of file IgSoAnimator.h.
Referenced by Ig3DAnimsCategory::attach(), IgSoAnimator(), and initAnim().