Update of /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11762/src/libopenvrml/openvrml
Modified Files:
browser.cpp
Added Files:
x3d_event_utilities.cpp x3d_event_utilities.h
x3d_key_device_sensor.cpp x3d_key_device_sensor.h
Log Message:
Added support for constructing X3D Interactive profile scenes. From Andrew Grieve <sgrieve@...>
--- NEW FILE: x3d_key_device_sensor.h ---
# ifndef OPENVRML_X3D_KEY_DEVICE_SENSOR_H
# define OPENVRML_X3D_KEY_DEVICE_SENSOR_H
namespace openvrml {
class browser;
}
extern "C" void register_key_device_sensor_node_classes(openvrml::browser & b);
# endif
--- NEW FILE: x3d_event_utilities.cpp ---
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*-
//
// OpenVRML
//
// Copyright 2006 Braden McDaniel
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[...1833 lines suppressed...]
* @param type the node_type associated with this node.
* @param scope the scope to which the node belongs.
*/
time_trigger_node::
time_trigger_node(const node_type & type,
const boost::shared_ptr<openvrml::scope> & scope):
node(type, scope),
bounded_volume_node(type, scope),
abstract_node<self_t>(type, scope),
child_node(type, scope),
set_boolean_listener_(*this),
trigger_time_emitter_(*this, this->trigger_time_)
{}
/**
* @brief Destroy.
*/
time_trigger_node::~time_trigger_node() throw ()
{}
}
Index: browser.cpp
===================================================================
RCS file: /cvsroot/openvrml/openvrml/src/libopenvrml/openvrml/browser.cpp,v
retrieving revision 1.154
retrieving revision 1.155
diff -C2 -d -r1.154 -r1.155
*** browser.cpp 25 Mar 2006 09:22:16 -0000 1.154
--- browser.cpp 26 Mar 2006 07:42:14 -0000 1.155
***************
*** 50,53 ****
--- 50,55 ----
# include "x3d_rendering.h"
# include "x3d_texturing.h"
+ # include "x3d_key_device_sensor.h"
+ # include "x3d_event_utilities.h"
namespace openvrml {
***************
*** 3851,3854 ****
--- 3853,3864 ----
+ class OPENVRML_LOCAL x3d_interactive_profile : public profile {
+ public:
+ static const char * const id;
+
+ x3d_interactive_profile();
+ };
+
+
class OPENVRML_LOCAL component {
public:
***************
*** 3895,3898 ****
--- 3905,3912 ----
succeeded = this->insert(key, new x3d_interchange_profile).second;
assert(succeeded);
+
+ key = x3d_interactive_profile::id;
+ succeeded = this->insert(key, new x3d_interactive_profile).second;
+ assert(succeeded);
}
***************
*** 3928,3932 ****
* @param[out] meta the scene metadata.
*
! * @exception openvrml::bad_media_type
* @exception openvrml::invalid_vrml
*/
--- 3942,3946 ----
* @param[out] meta the scene metadata.
*
! * @exception openvrml::bad_media_type
* @exception openvrml::invalid_vrml
*/
***************
*** 5882,5885 ****
--- 5896,5901 ----
register_rendering_node_classes(b);
register_texturing_node_classes(b);
+ register_key_device_sensor_node_classes(b);
+ register_event_utilities_node_classes(b);
}
}
***************
*** 11287,11290 ****
--- 11303,11658 ----
+ class OPENVRML_LOCAL x3d_pointing_device_sensor_component :
+ public component {
+ public:
+ static const char * const id;
+
+ virtual void add_to_scope(const openvrml::browser & b,
+ openvrml::scope & scope,
+ int support_level) const;
+ };
+
+ const char * const x3d_pointing_device_sensor_component::id =
+ "PointingDeviceSensor";
+
+ void
+ x3d_pointing_device_sensor_component::
+ add_to_scope(const openvrml::browser & b,
+ openvrml::scope & scope,
+ const int support_level) const
+ {
+ using namespace openvrml;
+
+ if (support_level >= 1) {
+ //
+ // CylinderSensor node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "autoOffset"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfstring_id,
+ "description"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sffloat_id,
+ "diskAngle"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "enabled"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sffloat_id,
+ "maxAngle"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sffloat_id,
+ "minAngle"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sffloat_id,
+ "offset"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isActive"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isOver"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfrotation_id,
+ "rotation_changed"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfvec3f_id,
+ "trackPoint_changed")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 12);
+ add_scope_entry(b,
+ "CylinderSensor",
+ interface_set,
+ "urn:X-openvrml:node:CylinderSensor",
+ scope);
+ }
+
+ //
+ // PlaneSensor node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "autoOffset"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfstring_id,
+ "description"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "enabled"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfvec2f_id,
+ "maxPosition"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfvec2f_id,
+ "minPosition"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfvec3f_id,
+ "offset"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isActive"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isOver"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfvec3f_id,
+ "trackPoint_changed"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfvec3f_id,
+ "translation_changed")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 11);
+ add_scope_entry(b,
+ "PlaneSensor",
+ interface_set,
+ "urn:X-openvrml:node:PlaneSensor",
+ scope);
+ }
+
+ //
+ // SphereSensor node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "autoOffset"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfstring_id,
+ "description"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "enabled"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfrotation_id,
+ "offset"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isActive"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isOver"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfrotation_id,
+ "rotation_changed"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfvec3f_id,
+ "trackPoint_changed")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 9);
+ add_scope_entry(b,
+ "SphereSensor",
+ interface_set,
+ "urn:X-openvrml:node:SphereSensor",
+ scope);
+ }
+
+ //
+ // TouchSensor node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfstring_id,
+ "description"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "enabled"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfvec3f_id,
+ "hitNormal_changed"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfvec3f_id,
+ "hitPoint_changed"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfvec2f_id,
+ "hitTexCoord_changed"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isActive"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isOver"),
+ node_interface(node_interface::eventout_id,
+ field_value::sftime_id,
+ "touchTime")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 9);
+ add_scope_entry(b,
+ "TouchSensor",
+ interface_set,
+ "urn:X-openvrml:node:TouchSensor",
+ scope);
+ }
+ }
+ }
+
+
+ class OPENVRML_LOCAL x3d_key_device_sensor_component : public component {
+ public:
+ static const char * const id;
+
+ virtual void add_to_scope(const openvrml::browser & b,
+ openvrml::scope & scope,
+ int support_level) const;
+ };
+
+ const char * const x3d_key_device_sensor_component::id = "KeyDeviceSensor";
+
+ void
+ x3d_key_device_sensor_component::
+ add_to_scope(const openvrml::browser & b,
+ openvrml::scope & scope,
+ const int support_level) const
+ {
+ using namespace openvrml;
+
+ if (support_level >= 1) {
+ //
+ // KeySensor node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "enabled"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfint32_id,
+ "actionKeyPress"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfint32_id,
+ "actionKeyRelease"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "altKey"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "controlKey"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isActive"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfstring_id,
+ "keyPress"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfstring_id,
+ "keyRelease"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "shiftKey")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 10);
+ add_scope_entry(b,
+ "KeySensor",
+ interface_set,
+ "urn:X-openvrml:node:KeySensor",
+ scope);
+ }
+ }
+ }
+
+
+ class OPENVRML_LOCAL x3d_environmental_sensor_component :
+ public component {
+ public:
+ static const char * const id;
+
+ virtual void add_to_scope(const openvrml::browser & b,
+ openvrml::scope & scope,
+ int support_level) const;
+ };
+
+ const char * const x3d_environmental_sensor_component::id =
+ "EnvironmentalSensor";
+
+ void
+ x3d_environmental_sensor_component::
+ add_to_scope(const openvrml::browser & b,
+ openvrml::scope & scope,
+ const int support_level) const
+ {
+ using namespace openvrml;
+
+ if (support_level >= 1) {
+ //
+ // ProximitySensor node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfvec3f_id,
+ "center"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "enabled"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfvec3f_id,
+ "size"),
+ node_interface(node_interface::eventout_id,
+ field_value::sftime_id,
+ "enterTime"),
+ node_interface(node_interface::eventout_id,
+ field_value::sftime_id,
+ "exitTime"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfvec3f_id,
+ "centerOfRotation_changed"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "isActive"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfrotation_id,
+ "orientation_changed"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfvec3f_id,
+ "position_changed")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 10);
+ add_scope_entry(b,
+ "ProximitySensor",
+ interface_set,
+ "urn:X-openvrml:node:ProximitySensor",
+ scope);
+ }
+ }
+ }
+
+
class OPENVRML_LOCAL x3d_navigation_component : public component {
public:
***************
*** 11483,11486 ****
--- 11851,12084 ----
+ class OPENVRML_LOCAL x3d_event_utilities_component : public component {
+ public:
+ static const char * const id;
+
+ virtual void add_to_scope(const openvrml::browser & b,
+ openvrml::scope & scope,
+ int support_level) const;
+ };
+
+ const char * const x3d_event_utilities_component::id = "EventUtilities";
+
+ void
+ x3d_event_utilities_component::add_to_scope(const openvrml::browser & b,
+ openvrml::scope & scope,
+ const int support_level) const
+ {
+ using namespace openvrml;
+
+ if (support_level >= 1) {
+ //
+ // BooleanFilter node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::eventin_id,
+ field_value::sfbool_id,
+ "set_boolean"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "inputFalse"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "inputNegate"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "inputTrue")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 5);
+ add_scope_entry(b,
+ "BooleanFilter",
+ interface_set,
+ "urn:X-openvrml:node:BooleanFilter",
+ scope);
+ }
+
+ //
+ // BooleanSequencer node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::eventin_id,
+ field_value::sfbool_id,
+ "next"),
+ node_interface(node_interface::eventin_id,
+ field_value::sfbool_id,
+ "previous"),
+ node_interface(node_interface::eventin_id,
+ field_value::sffloat_id,
+ "set_fraction"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::mffloat_id,
+ "key"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::mfbool_id,
+ "keyValue"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "value_changed")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 7);
+ add_scope_entry(b,
+ "BooleanSequencer",
+ interface_set,
+ "urn:X-openvrml:node:BooleanSequencer",
+ scope);
+ }
+
+ //
+ // BooleanToggle node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::eventin_id,
+ field_value::sfbool_id,
+ "set_boolean"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfbool_id,
+ "toggle")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 3);
+ add_scope_entry(b,
+ "BooleanToggle",
+ interface_set,
+ "urn:X-openvrml:node:BooleanToggle",
+ scope);
+ }
+
+ //
+ // BooleanTrigger node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::eventin_id,
+ field_value::sftime_id,
+ "set_triggerTime"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfbool_id,
+ "triggerTrue")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 3);
+ add_scope_entry(b,
+ "BooleanTrigger",
+ interface_set,
+ "urn:X-openvrml:node:BooleanTrigger",
+ scope);
+ }
+
+ //
+ // IntegerSequencer node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::eventin_id,
+ field_value::sfbool_id,
+ "next"),
+ node_interface(node_interface::eventin_id,
+ field_value::sfbool_id,
+ "previous"),
+ node_interface(node_interface::eventin_id,
+ field_value::sffloat_id,
+ "set_fraction"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::mffloat_id,
+ "key"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::mfint32_id,
+ "keyValue"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfint32_id,
+ "value_changed")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 7);
+ add_scope_entry(b,
+ "IntegerSequencer",
+ interface_set,
+ "urn:X-openvrml:node:IntegerSequencer",
+ scope);
+ }
+
+ //
+ // IntegerTrigger node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::eventin_id,
+ field_value::sfbool_id,
+ "set_boolean"),
+ node_interface(node_interface::exposedfield_id,
+ field_value::mfint32_id,
+ "integerKey"),
+ node_interface(node_interface::eventout_id,
+ field_value::sfint32_id,
+ "triggerValue")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 4);
+ add_scope_entry(b,
+ "IntegerTrigger",
+ interface_set,
+ "urn:X-openvrml:node:IntegerTrigger",
+ scope);
+ }
+
+ //
+ // TimeTrigger node
+ //
+ {
+ static const node_interface interfaces[] = {
+ node_interface(node_interface::exposedfield_id,
+ field_value::sfnode_id,
+ "metadata"),
+ node_interface(node_interface::eventin_id,
+ field_value::sfbool_id,
+ "set_boolean"),
+ node_interface(node_interface::eventout_id,
+ field_value::sftime_id,
+ "triggerTime")
+ };
+
+ static const node_interface_set interface_set(interfaces,
+ interfaces + 3);
+ add_scope_entry(b,
+ "TimeTrigger",
+ interface_set,
+ "urn:X-openvrml:node:TimeTrigger",
+ scope);
+ }
+ }
+ }
+
+
component_registry::component_registry()
{
***************
*** 11528,11531 ****
--- 12126,12144 ----
assert(succeeded);
+ key = x3d_pointing_device_sensor_component::id;
+ succeeded =
+ this->insert(key, new x3d_pointing_device_sensor_component).second;
+ assert(succeeded);
+
+ key = x3d_key_device_sensor_component::id;
+ succeeded =
+ this->insert(key, new x3d_key_device_sensor_component).second;
+ assert(succeeded);
+
+ key = x3d_environmental_sensor_component::id;
+ succeeded =
+ this->insert(key, new x3d_environmental_sensor_component).second;
+ assert(succeeded);
+
key = x3d_navigation_component::id;
succeeded = this->insert(key, new x3d_navigation_component).second;
***************
*** 11536,11539 ****
--- 12149,12157 ----
this->insert(key, new x3d_environmental_effects_component).second;
assert(succeeded);
+
+ key = x3d_event_utilities_component::id;
+ succeeded =
+ this->insert(key, new x3d_event_utilities_component).second;
+ assert(succeeded);
}
***************
*** 11605,11607 ****
--- 12223,12247 ----
this->add_component(x3d_environmental_effects_component::id, 1);
}
+
+
+ const char * const x3d_interactive_profile::id = "Interactive";
+
+ x3d_interactive_profile::x3d_interactive_profile()
+ {
+ this->add_component(x3d_core_component::id, 1);
+ this->add_component(x3d_time_component::id, 1);
+ this->add_component(x3d_grouping_component::id, 2);
+ this->add_component(x3d_rendering_component::id, 2);
+ this->add_component(x3d_shape_component::id, 1);
+ this->add_component(x3d_geometry3d_component::id, 3);
+ this->add_component(x3d_lighting_component::id, 2);
+ this->add_component(x3d_texturing_component::id, 2);
+ this->add_component(x3d_interpolation_component::id, 2);
+ this->add_component(x3d_pointing_device_sensor_component::id, 1);
+ this->add_component(x3d_key_device_sensor_component::id, 1);
+ this->add_component(x3d_environmental_sensor_component::id, 1);
+ this->add_component(x3d_navigation_component::id, 1);
+ this->add_component(x3d_environmental_effects_component::id, 1);
+ this->add_component(x3d_event_utilities_component::id, 1);
+ }
} // namespace
--- NEW FILE: x3d_event_utilities.h ---
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*-
//
// OpenVRML
//
// Copyright 2006 Braden McDaniel
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
# ifndef OPENVRML_X3D_EVENT_UTILITIES_H
# define OPENVRML_X3D_EVENT_UTILITIES_H
namespace openvrml {
class browser;
}
extern "C" void register_event_utilities_node_classes(openvrml::browser & b);
# endif
--- NEW FILE: x3d_key_device_sensor.cpp ---
// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; -*-
//
// OpenVRML
//
// Copyright 2006 Braden McDaniel
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
# ifdef HAVE_CONFIG_H
# include <config.h>
# endif
# include <boost/array.hpp>
# include <private.h>
# include "browser.h"
# include "node_impl_util.h"
# include "x3d_key_device_sensor.h"
using namespace openvrml;
using namespace openvrml::node_impl_util;
using namespace std;
namespace {
/**
* @brief Class object for KeySensor nodes.
*/
class OPENVRML_LOCAL key_sensor_class : public node_class {
public:
explicit key_sensor_class(openvrml::browser & browser);
virtual ~key_sensor_class() throw ();
private:
virtual const boost::shared_ptr<node_type>
do_create_type(const std::string & id,
const node_interface_set & interfaces) const
throw (unsupported_interface, std::bad_alloc);
};
}
void register_key_device_sensor_node_classes(openvrml::browser & b)
{
using boost::shared_ptr;
using openvrml::node_class;
b.add_node_class("urn:X-openvrml:node:KeySensor",
shared_ptr<node_class>(new key_sensor_class(b)));
}
namespace {
using namespace openvrml_;
class OPENVRML_LOCAL key_sensor_node : public abstract_node<key_sensor_node>,
public child_node {
friend class key_sensor_class;
exposedfield<sfbool> enabled_;
sfint32 action_key_press_;
sfint32_emitter action_key_press_emitter_;
sfint32 action_key_release_;
sfint32_emitter action_key_release_emitter_;
sfbool alt_key_;
sfbool_emitter alt_key_emitter_;
sfbool control_key_;
sfbool_emitter control_key_emitter_;
sfbool is_active_;
sfbool_emitter is_active_emitter_;
sfstring key_press_;
sfstring_emitter key_press_emitter_;
sfstring key_release_;
sfstring_emitter key_release_emitter_;
sfbool shift_key_;
sfbool_emitter shift_key_emitter_;
public:
key_sensor_node(const node_type & type,
const boost::shared_ptr<openvrml::scope> & scope);
virtual ~key_sensor_node() throw ();
};
/**
* @brief Construct.
*
* @param browser the browser associated with this key_sensor_class.
*/
key_sensor_class::key_sensor_class(openvrml::browser & browser):
node_class(browser)
{}
/**
* @brief Destroy.
*/
key_sensor_class::~key_sensor_class() throw ()
{}
/**
* @brief Create a node_type.
*
* @param id the name for the new node_type.
* @param interfaces the interfaces for the new node_type.
*
* @return a node_type_ptr to a node_type capable of creating KeySensor nodes.
*
* @exception unsupported_interface if @p interfaces includes an interface
* not supported by key_sensor_class.
* @exception std::bad_alloc if memory allocation fails.
*/
const boost::shared_ptr<openvrml::node_type>
key_sensor_class::do_create_type(const std::string & id,
const node_interface_set & interfaces) const
throw (unsupported_interface, std::bad_alloc)
{
typedef boost::array<node_interface, 10> supported_interfaces_t;
static const supported_interfaces_t supported_interfaces = {
node_interface(node_interface::exposedfield_id,
field_value::sfnode_id,
"metadata"),
node_interface(node_interface::exposedfield_id,
field_value::sfbool_id,
"enabled"),
node_interface(node_interface::eventout_id,
field_value::sfint32_id,
"actionKeyPress"),
node_interface(node_interface::eventout_id,
field_value::sfint32_id,
"actionKeyRelease"),
node_interface(node_interface::eventout_id,
field_value::sfbool_id,
"altKey"),
node_interface(node_interface::eventout_id,
field_value::sfbool_id,
"controlKey"),
node_interface(node_interface::eventout_id,
field_value::sfbool_id,
"isActive"),
node_interface(node_interface::eventout_id,
field_value::sfstring_id,
"keyPress"),
node_interface(node_interface::eventout_id,
field_value::sfstring_id,
"keyRelease"),
node_interface(node_interface::eventout_id,
field_value::sfbool_id,
"shiftKey")
};
typedef node_type_impl<key_sensor_node> node_type_t;
const boost::shared_ptr<node_type> type(new node_type_t(*this, id));
node_type_t & the_node_type = static_cast<node_type_t &>(*type);
for (node_interface_set::const_iterator interface(interfaces.begin());
interface != interfaces.end();
++interface) {
supported_interfaces_t::const_iterator supported_interface =
supported_interfaces.begin() - 1;
if (*interface == *++supported_interface) {
the_node_type.add_exposedfield(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_listener_ptr_ptr(
new node_type_t::event_listener_ptr<
abstract_node<key_sensor_node>::exposedfield<sfnode> >(
&key_sensor_node::metadata)),
node_type_t::field_ptr_ptr(
new node_type_t::field_ptr<
abstract_node<key_sensor_node>::exposedfield<sfnode> >(
&key_sensor_node::metadata)),
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
abstract_node<key_sensor_node>::exposedfield<sfnode> >(
&key_sensor_node::metadata)));
} else if (*interface == *++supported_interface) {
the_node_type.add_exposedfield(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_listener_ptr_ptr(
new node_type_t::event_listener_ptr<
abstract_node<key_sensor_node>::exposedfield<sfbool> >(
&key_sensor_node::enabled_)),
node_type_t::field_ptr_ptr(
new node_type_t::field_ptr<
abstract_node<key_sensor_node>::exposedfield<sfbool> >(
&key_sensor_node::enabled_)),
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
abstract_node<key_sensor_node>::exposedfield<sfbool> >(
&key_sensor_node::enabled_)));
} else if (*interface == *++supported_interface) {
the_node_type.add_eventout(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
key_sensor_node::sfint32_emitter>(
&key_sensor_node::action_key_press_emitter_)));
} else if (*interface == *++supported_interface) {
the_node_type.add_eventout(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
key_sensor_node::sfint32_emitter>(
&key_sensor_node::action_key_release_emitter_)));
} else if (*interface == *++supported_interface) {
the_node_type.add_eventout(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
key_sensor_node::sfbool_emitter>(
&key_sensor_node::alt_key_emitter_)));
} else if (*interface == *++supported_interface) {
the_node_type.add_eventout(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
key_sensor_node::sfbool_emitter>(
&key_sensor_node::control_key_emitter_)));
} else if (*interface == *++supported_interface) {
the_node_type.add_eventout(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
key_sensor_node::sfbool_emitter>(
&key_sensor_node::is_active_emitter_)));
} else if (*interface == *++supported_interface) {
the_node_type.add_eventout(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
key_sensor_node::sfstring_emitter>(
&key_sensor_node::key_press_emitter_)));
} else if (*interface == *++supported_interface) {
the_node_type.add_eventout(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
key_sensor_node::sfstring_emitter>(
&key_sensor_node::key_release_emitter_)));
} else if (*interface == *++supported_interface) {
the_node_type.add_eventout(
supported_interface->field_type,
supported_interface->id,
node_type_t::event_emitter_ptr_ptr(
new node_type_t::event_emitter_ptr<
key_sensor_node::sfbool_emitter>(
&key_sensor_node::shift_key_emitter_)));
} else {
throw unsupported_interface(*interface);
}
}
return type;
}
/**
* @class key_sensor_node
*
* @brief Represents KeySensor node instances.
*/
/**
* @var key_sensor_node::key_sensor_class
*
* @brief Class object for KeySensor nodes.
*/
/**
* @var key_sensor_node::enabled_
*
* @brief enabled exposedField
*/
/**
* @var key_sensor_node::action_key_press_
*
* @brief action_key_press eventOut
*/
/**
* @var key_sensor_node::action_key_release_
*
* @brief action_key_release eventOut
*/
/**
* @var key_sensor_node::alt_key_
*
* @brief alt_key eventOut
*/
/**
* @var key_sensor_node::control_key_
*
* @brief control_key eventOut
*/
/**
* @var key_sensor_node::is_active_
*
* @brief is_active eventOut
*/
/**
* @var key_sensor_node::key_press_
*
* @brief key_press eventOut
*/
/**
* @var key_sensor_node::key_release_
*
* @brief key_release eventOut
*/
/**
* @var key_sensor_node::shift_key_
*
* @brief shift_key eventOut
*/
/**
* @brief Construct.
*
* @param type the node_type associated with this node.
* @param scope the scope to which the node belongs.
*/
key_sensor_node::
key_sensor_node(const node_type & type,
const boost::shared_ptr<openvrml::scope> & scope):
node(type, scope),
bounded_volume_node(type, scope),
abstract_node<self_t>(type, scope),
child_node(type, scope),
enabled_(*this, true),
action_key_press_emitter_(*this, this->action_key_press_),
action_key_release_emitter_(*this, this->action_key_release_),
alt_key_emitter_(*this, this->alt_key_),
control_key_emitter_(*this, this->control_key_),
is_active_emitter_(*this, this->is_active_),
key_press_emitter_(*this, this->key_press_),
key_release_emitter_(*this, this->key_release_),
shift_key_emitter_(*this, this->shift_key_)
{}
/**
* @brief Destroy.
*/
key_sensor_node::~key_sensor_node() throw ()
{}
}
|