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

#include "Viewpoint.H"
#include "xrmlP.H"

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

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

static void process_Viewpoint_set_bind(SFNode* node, const fieldValue& value)
{
  Viewpoint* Viewpoint_node = dynamic_cast<Viewpoint*>(node);
  if (!Viewpoint_node)
    Fatal(-1, "process_Viewpoint_set_bind", "called for a non-Viewpoint node");
  Viewpoint_node->set_bind((const SFBool&)value);
}

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

static bool assign_Viewpoint_fieldOfView(SFNode* node, const fieldValue& value)
{
  Viewpoint* Viewpoint_node = dynamic_cast<Viewpoint*>(node);
  if (!Viewpoint_node)
    Fatal(-1, "assign_Viewpoint_fieldOfView", "called for a non-Viewpoint node");
  return Viewpoint_node->assign_fieldOfView((const SFFloat&)value);
}

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

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

static bool assign_Viewpoint_jump(SFNode* node, const fieldValue& value)
{
  Viewpoint* Viewpoint_node = dynamic_cast<Viewpoint*>(node);
  if (!Viewpoint_node)
    Fatal(-1, "assign_Viewpoint_jump", "called for a non-Viewpoint node");
  return Viewpoint_node->assign_jump((const SFBool&)value);
}

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

bool Viewpoint::assign_orientation(const SFRotation& value)
{
  // TODO: value range check!
  orientation = value;
  status |= orientation_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Viewpoint_orientation(SFNode* node, const fieldValue& value)
{
  Viewpoint* Viewpoint_node = dynamic_cast<Viewpoint*>(node);
  if (!Viewpoint_node)
    Fatal(-1, "assign_Viewpoint_orientation", "called for a non-Viewpoint node");
  return Viewpoint_node->assign_orientation((const SFRotation&)value);
}

void Viewpoint::set_orientation(const SFRotation& val)
{
  SFRotation tmpval(val);
  fieldValue v(&tmpval);
  interface[3]->assign(this, v);
}

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

static bool assign_Viewpoint_position(SFNode* node, const fieldValue& value)
{
  Viewpoint* Viewpoint_node = dynamic_cast<Viewpoint*>(node);
  if (!Viewpoint_node)
    Fatal(-1, "assign_Viewpoint_position", "called for a non-Viewpoint node");
  return Viewpoint_node->assign_position((const SFVec3f&)value);
}

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

bool Viewpoint::assign_description(const SFString& value)
{
  // TODO: value range check!
  description = value;
  status |= description_updated;
  timestamp = interface[5]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Viewpoint_description(SFNode* node, const fieldValue& value)
{
  Viewpoint* Viewpoint_node = dynamic_cast<Viewpoint*>(node);
  if (!Viewpoint_node)
    Fatal(-1, "assign_Viewpoint_description", "called for a non-Viewpoint node");
  return Viewpoint_node->assign_description((const SFString&)value);
}

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

void Viewpoint::post_bindTime(const SFTime& val)
{
  bindTime = val;
  status |= bindTime_updated;
  post_bindTime();
}

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

void Viewpoint::post_isBound(const SFBool& val)
{
  isBound = val;
  status |= isBound_updated;
  post_isBound();
}

Viewpoint::Viewpoint()
{
  interfaceMember* the_interface[8] = {
    new eventIn("set_bind", tSFBool, process_Viewpoint_set_bind),
    new exposedField("fieldOfView", fieldValue(&fieldOfView), assign_Viewpoint_fieldOfView),
    new exposedField("jump", fieldValue(&jump), assign_Viewpoint_jump),
    new exposedField("orientation", fieldValue(&orientation), assign_Viewpoint_orientation),
    new exposedField("position", fieldValue(&position), assign_Viewpoint_position),
    new field("description", fieldValue(&description), assign_Viewpoint_description),
    new eventOut("bindTime", fieldValue(&bindTime)),
    new eventOut("isBound", fieldValue(&isBound)),
  };
  SFNode::construct(ViewpointTypeId, 8, the_interface);

  fieldOfView = 0.785398;
  jump = 1;
  orientation = SFRotation(0,0,1,0);
  position = SFVec3f(0,0,10);
  description = "";
  bindTime = 0;
  isBound = 0;
  
  Bindable::util_init();
  Children::util_init();
  Viewpoint::util_init();
}

void Viewpoint::destruct(void)
{
  Viewpoint::util_destruct();
  Bindable::util_destruct();
  Children::util_destruct();
  SFNode::destruct();
}

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

void Viewpoint::clone_here(const Viewpoint& src)
{
  SFNode::clone(src);
  
  interface[1]->value = fieldValue(&fieldOfView);
  interface[2]->value = fieldValue(&jump);
  interface[3]->value = fieldValue(&orientation);
  interface[4]->value = fieldValue(&position);
  interface[5]->value = fieldValue(&description);
  interface[6]->value = fieldValue(&bindTime);
  interface[7]->value = fieldValue(&isBound);
  
  fieldOfView = src.fieldOfView;
  jump = src.jump;
  orientation = src.orientation;
  position = src.position;
  description = src.description;
  bindTime = src.bindTime;
  isBound = src.isBound;
  
  Bindable::util_clone(src);
  Children::util_clone(src);
  Viewpoint::util_clone(src);
}

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

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

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

}  // namespace xrml
