Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoDataSensor.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Nick Thompson (MMM yyyy)
25** Modified by : Gavin Bell (MMM yyyy)
26** Modified by : Paul Strauss (MMM yyyy)
27**=======================================================================*/
28/*=======================================================================
29 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
30 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
31 *** ***
32 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
33 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
34 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
35 *** ***
36 *** RESTRICTED RIGHTS LEGEND ***
37 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
38 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
39 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
40 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
41 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
42 *** ***
43 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
44 *** BORDEAUX, FRANCE ***
45 *** ALL RIGHTS RESERVED ***
46**=======================================================================*/
47/*=======================================================================
48** Modified by : VSG (MMM YYYY)
49**=======================================================================*/
50
51
52#ifndef _SO_DATA_SENSOR_
53#define _SO_DATA_SENSOR_
54
55class SoBase;
56class SoNode;
57class SoPath;
58class SoNotList;
59
60#include <Inventor/sensors/SoDelayQueueSensor.h>
61#include <Inventor/threads/SbThreadStorage.h>
62#include <Inventor/threads/SbThreadSpinlock.h>
63#include <Inventor/STL/list>
64
65#ifdef _WIN32
66#pragma warning(push)
67#pragma warning(disable:4251)
68#endif
69
229
230 public:
248
257 SoDataSensor(SoSensorCB *func, void *data);
258
259 // Destructor
260#ifndef HIDDEN_FROM_DOC
261 virtual ~SoDataSensor();
262#endif // HIDDEN_FROM_DOC
263
268 void setDeleteCallback(SoSensorCB *f, void *data = NULL)
269 { deleteFunc = f; deleteData = data; }
270
281
292
302
310 { doTrigPath = flag; }
311
320 { doTrigFastEditInfo = flag; }
321
327 { return doTrigPath; }
328
335 { return doTrigFastEditInfo; }
336
346
355
364
372
380
387
388 // Override unschedule() to reset trigNode and trigPath.
389 virtual void unschedule();
390
391 private:
392 // Override trigger to reset trigNode and trigPath, if
393 // necessary.
394 virtual void trigger();
395
396 // Propagates modification notification through an instance. By
397 // default, this schedules the sensor to be triggered and saves
398 // some information from the notification list for use by the
399 // callback function. Called by SoBase.
400 virtual void notify(SoNotList *list);
401
402 // This is called when the base (path, field, node, whatever) is
403 // deleted. All subclasses must implement this to do the right
404 // thing.
405 virtual void dyingReference() = 0;
406
407 // delete the list of dataSensor in the pending list
408 static void clearPendingDeleteList();
409
410 // add an SoDataSensor to the pending delete list
411 static void addToPendingDeleteList(SoDataSensor* dataSensor);
412
413 private:
414 // Invokes the delete callback
415 void invokeDeleteCallback();
416
417 private:
418 SoSensorCB* deleteFunc; // CB and data for when attached SoBase
419 void* deleteData; // is about to be deleted
420
421 class SoDataSensorData
422 {
423 public:
424 SoDataSensorData()
425 {
426 reset();
427 }
428 void reset()
429 {
430 trigNode = NULL;
431 trigField = NULL;
432 trigPath = NULL;
433
434 trigChildIndex = -1;
435 trigChild = NULL;
436 trigMFieldStartIndex = -1;
437 trigMFieldNumValues = -1;
438 m_flag.trigChangeType = UNSPECIFIED;
439 m_flag.trigFromFastEdit = 0;
440 }
441 // usefull for debug
442 bool isEmpty() const
443 {
444 return (trigNode==NULL) && (trigField==NULL) && (trigPath==NULL) && (m_flag.trigChangeType==UNSPECIFIED);
445 }
446
447 void setTriggerType(ChangeType changeType)
448 {
449 //assert(changeType< (1<<31));
450 m_flag.trigChangeType = changeType;
451 }
452
453 ChangeType getTriggerType() const
454 { return (ChangeType)(m_flag.trigChangeType); }
455
456 void setTriggerFromFastEdit(bool flag)
457 { m_flag.trigFromFastEdit = flag; }
458
459 bool isTriggerFromFastEdit() const
460 { return m_flag.trigFromFastEdit; }
461
462 public:
463 // members
464 SoNode* trigNode; // Node that triggered sensor
465 SoField* trigField; // Field that triggered sensor
466 SoPath* trigPath; // Path to trigNode
467 SoNode* trigChild; // changed child (if parent is SoGroup)
468 int trigChildIndex; // index of changed child in group (if parent is SoGroup)
469 int trigMFieldStartIndex; // index of the first value which change in the MField
470 int trigMFieldNumValues; // num of values which change in the MField
471 private:
472 struct {
474 unsigned int trigChangeType : 31;
476 unsigned int trigFromFastEdit : 1;
477 } m_flag;
478 };
479
480 // Store the current notification info (common to all threads)
481 // Doing multiple notification before trigger is managed will result in only the last
482 // notification to be triggered
483 // any access read/write to this member should be lock/unlock protected.
484 // as we cannot lock/unlock the trigger() method which use this member in readMode,
485 // we copy m_notifyData in m_triggerNotifyData (with a specific lock) in order to keep
486 // trigger call safe.
487 SoDataSensorData m_notifyData;
488
489 SoDataSensorData m_triggerNotifyData;
490 SbThreadSpinlock m_triggerNotifyDataMutex;
491
492 bool doTrigPath; // Whether to compute trigger path
493 bool doTrigFastEditInfo; // Whether to compute fastEditInfo
494
495 // manage pending delete list
496 static SbThreadSpinlock s_pendingDeleteListMutex;
497 static std::list<SoDataSensor*> s_pendingDeleteList;
498
499};
500
501#ifdef _WIN32
502#pragma warning(pop)
503#endif
504
505#endif /* _SO_DATA_SENSOR_ */
506
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable spinloc...
Base class for all nodes, paths, and engines.
Definition SoBase.h:111
Abstract base class for sensors attached to parts of a scene.
int getTriggerChildIndex() const
If this is a priority 0 data sensor, and a change to a group node's children caused this sensor to be...
SoNode * getTriggerChild() const
If this is a priority 0 data sensor, and a change to a group node's children caused this sensor to be...
virtual void unschedule()
If this sensor is scheduled, removes it from the delay queue so that it will not be triggered.
SoDataSensor(SoSensorCB *func, void *data)
Constructor that takes standard callback function and data.
SoDataSensor()
Constructor.
SoField * getTriggerField() const
If this is a priority 0 data sensor, returns the field that was modified that caused this sensor to t...
SbBool getTriggerPathFlag() const
Queries the flag that indicates whether the trigger path (see getTriggerPath()) is available to call...
void setTriggerPathFlag(SbBool flag)
Sets the flag that indicates whether the trigger path (see getTriggerPath()) is available to callbac...
int getTriggerMFieldNumValues() const
If this is a priority 0 data sensor, and a change in the data values of a multiple field (e....
SbBool getTriggerFastEditInfoFlag() const
Queries the flag that indicates whether the trigger path fastEdit info (see getTriggerFastEditInfo())...
SoPath * getTriggerPath() const
If this is a priority 0 data sensor, returns a path to the node that caused this sensor to trigger.
SoNode * getTriggerNode() const
If this is a priority 0 data sensor, returns the node that was modified that caused this sensor to tr...
ChangeType getTriggerType() const
If this is a priority 0 data sensor, returns the type of change that occurred.
int getTriggerMFieldStartIndex() const
If this is a priority 0 data sensor, and a change in the data values of a multiple field (e....
int getTriggerFastEditInfo() const
Returns true if the triggered changes come from a field or node that was below a Separator with a fas...
ChangeType
Change type.
@ GROUP_REPLACE_CHILD
Group replace child.
@ UNSPECIFIED
Unspecified.
@ GROUP_INSERT_CHILD
Group insert child.
@ FIELD_MULTIVALUE
Field multivalue.
@ GROUP_REMOVE_ALL_CHILDREN
Group remove all children.
@ GROUP_REMOVE_CHILD
Group remove child.
@ GROUP_ADD_CHILD
Group add child.
void setDeleteCallback(SoSensorCB *f, void *data=NULL)
Sets a callback that will be called when the object the sensor is sensing is deleted.
void setTriggerFastEditInfoFlag(SbBool flag)
Sets the flag that indicates whether the trigger path fastEdit info (see getTriggerFastEditInfo()) is...
Abstract base class for sensors not dependent on time.
Base class for all fields.
Definition SoField.h:234
Abstract base class for all database nodes.
Definition SoNode.h:145
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
void SoSensorCB(void *data, SoSensor *sensor)
This typedef defines the calling sequence for all callbacks from sensors.
Definition SoSensor.h:68
int SbBool
Boolean type.
Definition SbBase.h:87