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

#include "CylinderSensor.H"
#include "xrmlP.H"

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

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

bool CylinderSensor::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_CylinderSensor_autoOffset(SFNode* node, const fieldValue& value)
{
  CylinderSensor* CylinderSensor_node = dynamic_cast<CylinderSensor*>(node);
  if (!CylinderSensor_node)
    Fatal(-1, "assign_CylinderSensor_autoOffset", "called for a non-CylinderSensor node");
  return CylinderSensor_node->assign_autoOffset((const SFBool&)value);
}

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

bool CylinderSensor::assign_diskAngle(const SFFloat& value)
{
  // TODO: value range check!
  diskAngle = value;
  status |= diskAngle_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_CylinderSensor_diskAngle(SFNode* node, const fieldValue& value)
{
  CylinderSensor* CylinderSensor_node = dynamic_cast<CylinderSensor*>(node);
  if (!CylinderSensor_node)
    Fatal(-1, "assign_CylinderSensor_diskAngle", "called for a non-CylinderSensor node");
  return CylinderSensor_node->assign_diskAngle((const SFFloat&)value);
}

void CylinderSensor::set_diskAngle(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[1]->assign(this, v);
}

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

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

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

bool CylinderSensor::assign_maxAngle(const SFFloat& value)
{
  // TODO: value range check!
  maxAngle = value;
  status |= maxAngle_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_CylinderSensor_maxAngle(SFNode* node, const fieldValue& value)
{
  CylinderSensor* CylinderSensor_node = dynamic_cast<CylinderSensor*>(node);
  if (!CylinderSensor_node)
    Fatal(-1, "assign_CylinderSensor_maxAngle", "called for a non-CylinderSensor node");
  return CylinderSensor_node->assign_maxAngle((const SFFloat&)value);
}

void CylinderSensor::set_maxAngle(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

bool CylinderSensor::assign_minAngle(const SFFloat& value)
{
  // TODO: value range check!
  minAngle = value;
  status |= minAngle_updated;
  timestamp = interface[4]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_CylinderSensor_minAngle(SFNode* node, const fieldValue& value)
{
  CylinderSensor* CylinderSensor_node = dynamic_cast<CylinderSensor*>(node);
  if (!CylinderSensor_node)
    Fatal(-1, "assign_CylinderSensor_minAngle", "called for a non-CylinderSensor node");
  return CylinderSensor_node->assign_minAngle((const SFFloat&)value);
}

void CylinderSensor::set_minAngle(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[4]->assign(this, v);
}

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

static bool assign_CylinderSensor_offset(SFNode* node, const fieldValue& value)
{
  CylinderSensor* CylinderSensor_node = dynamic_cast<CylinderSensor*>(node);
  if (!CylinderSensor_node)
    Fatal(-1, "assign_CylinderSensor_offset", "called for a non-CylinderSensor node");
  return CylinderSensor_node->assign_offset((const SFFloat&)value);
}

void CylinderSensor::set_offset(const SFFloat& val)
{
  SFFloat tmpval(val);
  fieldValue v(&tmpval);
  interface[5]->assign(this, v);
}

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

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

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

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

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

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

CylinderSensor::CylinderSensor()
{
  interfaceMember* the_interface[9] = {
    new exposedField("autoOffset", fieldValue(&autoOffset), assign_CylinderSensor_autoOffset),
    new exposedField("diskAngle", fieldValue(&diskAngle), assign_CylinderSensor_diskAngle),
    new exposedField("enabled", fieldValue(&enabled), assign_CylinderSensor_enabled),
    new exposedField("maxAngle", fieldValue(&maxAngle), assign_CylinderSensor_maxAngle),
    new exposedField("minAngle", fieldValue(&minAngle), assign_CylinderSensor_minAngle),
    new exposedField("offset", fieldValue(&offset), assign_CylinderSensor_offset),
    new eventOut("isActive", fieldValue(&isActive)),
    new eventOut("rotation_changed", fieldValue(&rotation_changed)),
    new eventOut("trackPoint_changed", fieldValue(&trackPoint_changed)),
  };
  SFNode::construct(CylinderSensorTypeId, 9, the_interface);

  autoOffset = 1;
  diskAngle = 0.262;
  enabled = 1;
  maxAngle = -1;
  minAngle = 0;
  offset = 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();
  CylinderSensor::util_init();
}

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

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

void CylinderSensor::clone_here(const CylinderSensor& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&autoOffset);
  interface[1]->value = fieldValue(&diskAngle);
  interface[2]->value = fieldValue(&enabled);
  interface[3]->value = fieldValue(&maxAngle);
  interface[4]->value = fieldValue(&minAngle);
  interface[5]->value = fieldValue(&offset);
  interface[6]->value = fieldValue(&isActive);
  interface[7]->value = fieldValue(&rotation_changed);
  interface[8]->value = fieldValue(&trackPoint_changed);
  
  autoOffset = src.autoOffset;
  diskAngle = src.diskAngle;
  enabled = src.enabled;
  maxAngle = src.maxAngle;
  minAngle = src.minAngle;
  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);
  CylinderSensor::util_clone(src);
}

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

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

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

}  // namespace xrml
