H3D API  2.4.1
X3DTouchSensorNode.h
Go to the documentation of this file.
1 // Copyright 2004-2019, SenseGraphics AB
3 //
4 // This file is part of H3D API.
5 //
6 // H3D API is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // H3D API is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with H3D API; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 //
20 // A commercial license is also available. Please contact us at
21 // www.sensegraphics.com for more information.
22 //
23 //
27 //
29 #ifndef __X3DTOUCHSENSORNODE_H__
30 #define __X3DTOUCHSENSORNODE_H__
31 
33 #include <H3D/SFTime.h>
34 
35 namespace H3D {
36 
44 
45  class H3DAPI_API X3DTouchSensorNode :
47  public:
48 
53  class H3DAPI_API SetTouchTime:
54  public AutoUpdate< TypedField < SFBool, SFBool > > {
55  public:
56  virtual void setValue( const bool &b, int _id = 0 ) {
57  SFBool::setValue( b, _id );
58  }
59  protected:
60  virtual void update() {
62  bool _isActive = static_cast< SFBool * >( routes_in[0] )->getValue();
63  X3DTouchSensorNode *ts =
64  static_cast< X3DTouchSensorNode * >( getOwner() );
65  if( !_isActive && ts->isOver->getValue() ) {
66  ts->touchTime->setValue( event.time_stamp, ts->id );
67  }
68  }
69  };
70 #ifdef __BORLANDC__
71  friend class SetTouchTime;
72 #endif
73 
75  X3DTouchSensorNode( Inst< SFString > _description = 0,
76  Inst< SFBool > _enabled = 0,
77  Inst< SFNode > _metadata = 0,
78  Inst< SFBool > _isActive = 0,
79  Inst< SFBool > _isOver = 0,
80  Inst< SFTime > _touchTime = 0 );
81 
82  // Fields
95  H3DUniquePtr< SFTime > touchTime;
96 
99 
100  protected:
102  H3DUniquePtr< SetTouchTime > setTouchTime;
103  };
104 }
105 
106 #endif
Contains the SFTime field class.
Header file for X3DPointingDeviceSensorNode, X3D scene-graph node.
The SFBool field contains a single boolean value.
Definition: SFBool.h:41
virtual void setValue(const bool &v, int id=0)
Set the value of the field.
Definition: SField.h:215
virtual void update()
Make the field up to date given that an event has occured.
Definition: SField.h:181
This abstract node type is the base type for all pointing device sensors.
Definition: X3DPointingDeviceSensorNode.h:109
H3DUniquePtr< SFBool > isOver
The isOver field reflects the state of the pointing device with regard to whether it is pointing towa...
Definition: X3DPointingDeviceSensorNode.h:149
The SetTouchTime class is specialize field to generate a touchTime event.
Definition: X3DTouchSensorNode.h:54
This abstract node type is the base type for all touch-style pointing device sensors.
Definition: X3DTouchSensorNode.h:46
H3DUniquePtr< SetTouchTime > setTouchTime
instance of specialized field used to set the touchTime field.
Definition: X3DTouchSensorNode.h:102
H3DUniquePtr< SFTime > touchTime
The field touchTime is generated when all three of the following conditions are true:
Definition: X3DTouchSensorNode.h:95
static H3DNodeDatabase database
The H3DNodeDatabase for this node.
Definition: X3DTouchSensorNode.h:98
Type getValue(const char *s, const char *&rest)
Function that reads characters from a char * and converts them to a given type.
Definition: X3DFieldConversion.h:134
H3D API namespace.
Definition: Anchor.h:38
The AutoUpdate field is a template to force the BaseField to update itself as soon as an event is rec...
Definition: FieldTemplates.h:130
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194