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

#include "SphereSensor.H"
#include "xrmlP.H"

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

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

bool SphereSensor::assign_autoOffset(const SFBool& value)
{
  // TODO: value range check!
  autoOffset = value;
  status |= autoOffset_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SphereSensor_autoOffset(SFNode* node, const fieldValue& value)
{
  SphereSensor* SphereSensor_node = dynamic_cast<SphereSensor*>(node);
  if (!SphereSensor_node)
    Fatal(-1, "assign_SphereSensor_autoOffset", "called for a non-SphereSensor node");
  return SphereSensor_node->assign_autoOffset((const SFBool&)value);
}

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

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

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

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

bool SphereSensor::assign_offset(const SFRotation& value)
{
  // TODO: value range check!
  offset = value;
  status |= offset_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_SphereSensor_offset(SFNode* node, const fieldValue& value)
{
  SphereSensor* SphereSensor_node = dynamic_cast<SphereSensor*>(node);
  if (!SphereSensor_node)
    Fatal(-1, "assign_SphereSensor_offset", "called for a non-SphereSensor node");
  return SphereSensor_node->assign_offset((const SFRotation&)value);
}

void SphereSensor::set_offset(const SFRotation& val)
{
  SFRotation tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

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

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

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

void SphereSensor::post_rotation_changed(const SFRotation& val)
{
  rotation_changed = val;
  status |= rotation_changed_updated;
  post_rotation_changed();
}

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

void SphereSensor::post_trackPoint_changed(const SFVec3f& val)
{
  trackPoint_changed = val;
  status |= trackPoint_changed_updated;
  post_trackPoint_changed();
}

SphereSensor::SphereSensor()
{
  interfaceMember* the_interface[6] = {
    new exposedField("autoOffset", fieldValue(&autoOffset), assign_SphereSensor_autoOffset),
    new exposedField("enabled", fieldValue(&enabled), assign_SphereSensor_enabled),
    new exposedField("offset", fieldValue(&offset), assign_SphereSensor_offset),
    new eventOut("isActive", fieldValue(&isActive)),
    new eventOut("rotation_changed", fieldValue(&rotation_changed)),
    new eventOut("trackPoint_changed", fieldValue(&trackPoint_changed)),
  };
  SFNode::construct(SphereSensorTypeId, 6, the_interface);

  autoOffset = 1;
  enabled = 1;
  offset = SFRotation(0,1,0,0);
  isActive = 0;
  rotation_changed = SFRotation(0,0,0,0);
  trackPoint_changed = SFVec3f(0,0,0);
  
  Sensor::util_init();
  PointingDeviceSensor::util_init();
  DragSensor::util_init();
  Children::util_init();
  SphereSensor::util_init();
}

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

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

void SphereSensor::clone_here(const SphereSensor& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&autoOffset);
  interface[1]->value = fieldValue(&enabled);
  interface[2]->value = fieldValue(&offset);
  interface[3]->value = fieldValue(&isActive);
  interface[4]->value = fieldValue(&rotation_changed);
  interface[5]->value = fieldValue(&trackPoint_changed);
  
  autoOffset = src.autoOffset;
  enabled = src.enabled;
  offset = src.offset;
  isActive = src.isActive;
  rotation_changed = src.rotation_changed;
  trackPoint_changed = src.trackPoint_changed;
  
  Sensor::util_clone(src);
  PointingDeviceSensor::util_clone(src);
  DragSensor::util_clone(src);
  Children::util_clone(src);
  SphereSensor::util_clone(src);
}

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

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

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

}  // namespace xrml
