// TouchSensorP.C: TouchSensor nodes (private source).
// Automatically generated with nodegen 0.5a - do not edit.

#include "TouchSensor.H"
#include "xrmlP.H"

namespace xrml {
int TouchSensor::major_version(void) { return 0; }
int TouchSensor::minor_version(void) { return 5; }
bool TouchSensor::is_leaf_class(void) { return true; }

bool IsTouchSensor(SFNode* node)
{
  return (dynamic_cast<TouchSensor*>(node) != 0);
}

bool TouchSensor::assign_enabled(const SFBool& value)
{
  // TODO: value range check!
  enabled = value;
  status |= enabled_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_TouchSensor_enabled(SFNode* node, const fieldValue& value)
{
  TouchSensor* TouchSensor_node = dynamic_cast<TouchSensor*>(node);
  if (!TouchSensor_node)
    Fatal(-1, "assign_TouchSensor_enabled", "called for a non-TouchSensor node");
  return TouchSensor_node->assign_enabled((const SFBool&)value);
}

void TouchSensor::set_enabled(const SFBool& val)
{
  SFBool tmpval(val);
  fieldValue v(&tmpval);
  interface[0]->assign(this, v);
}

void TouchSensor::post_hitNormal_changed(void)
{
  interface[1]->post(this, interface[1]->value);
}

void TouchSensor::post_hitNormal_changed(const SFVec3f& val)
{
  hitNormal_changed = val;
  status |= hitNormal_changed_updated;
  post_hitNormal_changed();
}

void TouchSensor::post_hitPoint_changed(void)
{
  interface[2]->post(this, interface[2]->value);
}

void TouchSensor::post_hitPoint_changed(const SFVec3f& val)
{
  hitPoint_changed = val;
  status |= hitPoint_changed_updated;
  post_hitPoint_changed();
}

void TouchSensor::post_hitTexCoord_changed(void)
{
  interface[3]->post(this, interface[3]->value);
}

void TouchSensor::post_hitTexCoord_changed(const SFVec2f& val)
{
  hitTexCoord_changed = val;
  status |= hitTexCoord_changed_updated;
  post_hitTexCoord_changed();
}

void TouchSensor::post_isActive(void)
{
  interface[4]->post(this, interface[4]->value);
}

void TouchSensor::post_isActive(const SFBool& val)
{
  isActive = val;
  status |= isActive_updated;
  post_isActive();
}

void TouchSensor::post_isOver(void)
{
  interface[5]->post(this, interface[5]->value);
}

void TouchSensor::post_isOver(const SFBool& val)
{
  isOver = val;
  status |= isOver_updated;
  post_isOver();
}

void TouchSensor::post_touchTime(void)
{
  interface[6]->post(this, interface[6]->value);
}

void TouchSensor::post_touchTime(const SFTime& val)
{
  touchTime = val;
  status |= touchTime_updated;
  post_touchTime();
}

TouchSensor::TouchSensor()
{
  interfaceMember* the_interface[7] = {
    new exposedField("enabled", fieldValue(&enabled), assign_TouchSensor_enabled),
    new eventOut("hitNormal_changed", fieldValue(&hitNormal_changed)),
    new eventOut("hitPoint_changed", fieldValue(&hitPoint_changed)),
    new eventOut("hitTexCoord_changed", fieldValue(&hitTexCoord_changed)),
    new eventOut("isActive", fieldValue(&isActive)),
    new eventOut("isOver", fieldValue(&isOver)),
    new eventOut("touchTime", fieldValue(&touchTime)),
  };
  SFNode::construct(TouchSensorTypeId, 7, the_interface);

  enabled = 1;
  hitNormal_changed = SFVec3f(0,0,0);
  hitPoint_changed = SFVec3f(0,0,0);
  hitTexCoord_changed = SFVec2f(0,0);
  isActive = 0;
  isOver = 0;
  touchTime = 0;
  
  Sensor::util_init();
  PointingDeviceSensor::util_init();
  Children::util_init();
  TouchSensor::util_init();
}

void TouchSensor::destruct(void)
{
  TouchSensor::util_destruct();
  PointingDeviceSensor::util_destruct();
  Sensor::util_destruct();
  Children::util_destruct();
  SFNode::destruct();
}

TouchSensor::~TouchSensor()
{
  destruct();
}

void TouchSensor::clone_here(const TouchSensor& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&enabled);
  interface[1]->value = fieldValue(&hitNormal_changed);
  interface[2]->value = fieldValue(&hitPoint_changed);
  interface[3]->value = fieldValue(&hitTexCoord_changed);
  interface[4]->value = fieldValue(&isActive);
  interface[5]->value = fieldValue(&isOver);
  interface[6]->value = fieldValue(&touchTime);
  
  enabled = src.enabled;
  hitNormal_changed = src.hitNormal_changed;
  hitPoint_changed = src.hitPoint_changed;
  hitTexCoord_changed = src.hitTexCoord_changed;
  isActive = src.isActive;
  isOver = src.isOver;
  touchTime = src.touchTime;
  
  Sensor::util_clone(src);
  PointingDeviceSensor::util_clone(src);
  Children::util_clone(src);
  TouchSensor::util_clone(src);
}

TouchSensor::TouchSensor(const TouchSensor& src)
{
  clone_here(src);
}

TouchSensor& TouchSensor::operator=(const TouchSensor& src)
{
  if (this != &src) {
    destruct();
    clone_here(src);
  }
  return *this;
}

SFNode* TouchSensor::instantiate(Proto *enclosing_proto)
{
  if (nameIndex>=0)
    // named node: return pointer to pre-made instance
    return enclosing_proto ? enclosing_proto->namedNodes[nameIndex] : this;
  
  TouchSensor* instance = new TouchSensor(*this);
  instance->instantiate_interface(enclosing_proto);
  return instance;
}

}  // namespace xrml
