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

#include "PlaneSensor.H"
#include "xrmlP.H"

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

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

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

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

bool PlaneSensor::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_PlaneSensor_enabled(SFNode* node, const fieldValue& value)
{
  PlaneSensor* PlaneSensor_node = dynamic_cast<PlaneSensor*>(node);
  if (!PlaneSensor_node)
    Fatal(-1, "assign_PlaneSensor_enabled", "called for a non-PlaneSensor node");
  return PlaneSensor_node->assign_enabled((const SFBool&)value);
}

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

bool PlaneSensor::assign_maxPosition(const SFVec2f& value)
{
  // TODO: value range check!
  maxPosition = value;
  status |= maxPosition_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PlaneSensor_maxPosition(SFNode* node, const fieldValue& value)
{
  PlaneSensor* PlaneSensor_node = dynamic_cast<PlaneSensor*>(node);
  if (!PlaneSensor_node)
    Fatal(-1, "assign_PlaneSensor_maxPosition", "called for a non-PlaneSensor node");
  return PlaneSensor_node->assign_maxPosition((const SFVec2f&)value);
}

void PlaneSensor::set_maxPosition(const SFVec2f& val)
{
  SFVec2f tmpval(val);
  fieldValue v(&tmpval);
  interface[2]->assign(this, v);
}

bool PlaneSensor::assign_minPosition(const SFVec2f& value)
{
  // TODO: value range check!
  minPosition = value;
  status |= minPosition_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_PlaneSensor_minPosition(SFNode* node, const fieldValue& value)
{
  PlaneSensor* PlaneSensor_node = dynamic_cast<PlaneSensor*>(node);
  if (!PlaneSensor_node)
    Fatal(-1, "assign_PlaneSensor_minPosition", "called for a non-PlaneSensor node");
  return PlaneSensor_node->assign_minPosition((const SFVec2f&)value);
}

void PlaneSensor::set_minPosition(const SFVec2f& val)
{
  SFVec2f tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

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

static bool assign_PlaneSensor_offset(SFNode* node, const fieldValue& value)
{
  PlaneSensor* PlaneSensor_node = dynamic_cast<PlaneSensor*>(node);
  if (!PlaneSensor_node)
    Fatal(-1, "assign_PlaneSensor_offset", "called for a non-PlaneSensor node");
  return PlaneSensor_node->assign_offset((const SFVec3f&)value);
}

void PlaneSensor::set_offset(const SFVec3f& val)
{
  SFVec3f tmpval(val);
  fieldValue v(&tmpval);
  interface[4]->assign(this, v);
}

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

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

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

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

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

void PlaneSensor::post_translation_changed(const SFVec3f& val)
{
  translation_changed = val;
  status |= translation_changed_updated;
  post_translation_changed();
}

PlaneSensor::PlaneSensor()
{
  interfaceMember* the_interface[8] = {
    new exposedField("autoOffset", fieldValue(&autoOffset), assign_PlaneSensor_autoOffset),
    new exposedField("enabled", fieldValue(&enabled), assign_PlaneSensor_enabled),
    new exposedField("maxPosition", fieldValue(&maxPosition), assign_PlaneSensor_maxPosition),
    new exposedField("minPosition", fieldValue(&minPosition), assign_PlaneSensor_minPosition),
    new exposedField("offset", fieldValue(&offset), assign_PlaneSensor_offset),
    new eventOut("isActive", fieldValue(&isActive)),
    new eventOut("trackPoint_changed", fieldValue(&trackPoint_changed)),
    new eventOut("translation_changed", fieldValue(&translation_changed)),
  };
  SFNode::construct(PlaneSensorTypeId, 8, the_interface);

  autoOffset = 1;
  enabled = 1;
  maxPosition = SFVec2f(-1,-1);
  minPosition = SFVec2f(0,0);
  offset = SFVec3f(0,0,0);
  isActive = 0;
  trackPoint_changed = SFVec3f(0,0,0);
  translation_changed = SFVec3f(0,0,0);
  
  Sensor::util_init();
  PointingDeviceSensor::util_init();
  DragSensor::util_init();
  Children::util_init();
  PlaneSensor::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
