Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
PoBase.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2023 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24#ifndef _PO_BASE_
25#define _PO_BASE_
26
27class PbBase ;
28class SoAction ;
29class SoFieldSensor ;
30class PbDataMapping ;
31class SoMaterial;
33class SoQuadMesh;
37class SoLineSet;
38class SoCache ;
39class SoShape;
40
41#include <MeshViz/PoMeshViz.h>
42#include <MeshViz/PbBasic.h>
44
50#include <Inventor/caches/SoCache.h>
51
52#define PO_KIT_ADD_FIELD(_fieldName,_defValue,_fieldList)\
53 _fieldList.append(&_fieldName) ;\
54 SO_KIT_ADD_FIELD(_fieldName, _defValue) ;
55
74class PoBase : public SoBaseKit {
75
77
78 SO_KIT_CATALOG_ENTRY_HEADER(catchActionCallback) ;
79 SO_KIT_CATALOG_ENTRY_HEADER(alternateRep) ;
80 SO_KIT_CATALOG_ENTRY_HEADER(catchActionLevel2Callback) ;
81 SO_KIT_CATALOG_ENTRY_HEADER(appearance) ;
82 SO_KIT_CATALOG_ENTRY_HEADER(domainTransform) ;
83
84
85 public:
86
87
88
102
116
124
125
129 typedef void PoRebuildCB(void *userData, PoBase *base) ;
130
143 void setUpdateMethod(UpdateMethodType type) { m_updateMethodType = type ; }
144
148 UpdateMethodType getUpdateMethod() const { return m_updateMethodType ; }
149
164
169
176 void setDomain(PbDomain *dom) ;
177
182 const PbDomain* getDomain() const ;
183
187 void touchKit() ;
188
192 SbBool isModified() const { return m_hasBeenModified ; }
193
198 { return m_isObjBuilt ; }
199
211 virtual void rebuild() {} ;
212
218 void addPreRebuildCallback(PoRebuildCB *cb, void *data) ;
219
225 void addPostRebuildCallback(PoRebuildCB *cb, void *data) ;
226
227
233 void removePreRebuildCallback(PoRebuildCB *cb, void *data=NULL) ;
234
241
252 static void setTextType(TextType type) ;
253
258
276 static void setVRML2Mode(SbBool flag) ;
277
282
286 virtual SoNode *copy(SbBool copyConnections = FALSE) const ;
287
291 virtual SbBool affectsState() const ;
292
293 /*----------------------------------------------------------------------------*/
294 private:
295
301 static void init() ;
302 static void finish() ;
303 static bool isInitialized();
304
305 static void initClass() ;
306 static void exitClass() ;
307
308 // Overload the method write to store the current write action
309 virtual void write(SoWriteAction *action) ;
310
311 // Manage the connection with PbBase objects
312 virtual void basicObjectChange(PbBase *basicObj) ;
313
314 // Enable domain transform
315 void enableDomainTransform(SbBool flag)
316 { m_isDomainTrans = flag ; }
317
318 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
319 SoGroup *group);
320 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
321 SoQuadMesh *shape, SoGroup *father_of_shape, int child_index);
322 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
323 SoIndexedTriangleStripSet *shape, SoGroup *father_of_shape, int child_index);
324 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
325 SoIndexedFaceSet *shape, SoGroup *father_of_shape, int child_index);
326 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
327 SoIndexedLineSet *shape, SoGroup *father_of_shape, int child_index);
328 SoShape* deleteTransparencyParts(const PbDataMapping *data_mapping, const SoMaterial *material, SoMaterialBinding *material_binding,
329 SoLineSet *shape, SoGroup *father_of_shape, int child_index);
330
331 void setStateValid( bool isStateValid )
332 {
333 m_isStateValid = isStateValid;
334 }
335
336 // Store and Get the current state
337 void setState( SoAction* action );
338 SoState* getState() const;
339
340 private:
341 // Implements actions
342 virtual void GLRender(SoGLRenderAction *action);
343
344 private:
345 // structure of a list of sensors
346 struct FieldSensorList {
347 int numSensors ;
348 SoFieldSensor **sensors ;
349 } ;
350
351 // Constructor and destructor
352 // actionCallback is the callback function called
353 // when the kit is traversed (callback of the node
354 // SoCallback).
355 PoBase(SoCallbackCB *actionCallback=NULL) ;
356 virtual ~PoBase() ;
357
358 // Methods
359 virtual void setDefaultOnNonWritingFields() ;
360 virtual SbBool setUpConnections(SbBool onOff, SbBool doItAlways = FALSE) ;
361
362 // Copies the contents of the given nodekit into this instance
363 virtual void copyContents(const SoFieldContainer *fromFC,
364 SbBool copyConnections);
365
366 // Change connection with a PbBase object
367 void changeConnection(PbBase *oldObj, PbBase *newObj) ;
368
369 // Called when a Pb object change
370 virtual void manageBasicObjectChange(PbBase *basicObj, PbBase **obj) ;
371
372 // Indicate if a field has changed
373 SbBool isFieldHasChanged(const SoField *field) ;
374
375 // Indicate if one of fields has changed
376 SbBool isAnyFieldsHasChanged()
377 { return m_someFieldsHasChanged ; }
378
379 // Empty list of changed fields
380 void emptyListFieldsChanged() { m_listFieldsChanged.truncate(0) ; }
381
382 // Set a list of field at default value.
383 void setListFieldsDefault(const SoFieldList &fieldLst) ;
384
385 // Set domain scale transformation
386 void setDomainTransform(PbDomain *domain) ;
387
388 // Is domain scale transform
389 SbBool isDomainTransformEnabled() const
390 { return m_isDomainTrans ; }
391
392 // Set domain used or not for rebuild
393 void setDomainUsedForRebuild(SbBool flag)
394 { m_isDomUseForRebuild = flag ; }
395
396 // Is domain used for rebuild
397 SbBool isDomainUsedForRebuild() const
398 { return m_isDomUseForRebuild ; }
399
400 // Method which does somethings before rebuild a node
401 virtual void preRebuild() ;
402
403 // Method which does somethings after rebuild a node
404 virtual void postRebuild() ;
405
406 // Set light model for the part "appearence"
407 void setLightModel(SoLightModel::Model model) ;
408
409 // Set draw style (only field style) for am Appearence Kit
410 void setDrawStyleAK(const SbString& partName, SoDrawStyle::Style style=SoDrawStyle::LINES) ;
411
412 // Indicate if fields have changed must be stored
413 // Not store by default
414 void storeFieldsChanged(SbBool store)
415 { needToStoreFieldsChanged = store ; }
416
417 // Methods to handles list of sensors attached to fields
418 // The method createFieldSensorList() must be called after all
419 // field was created
420 void createFieldSensorList(int numFields, FieldSensorList *sensorList) ;
421 void deleteFieldSensorList(FieldSensorList *sensorList) ;
422 void attachFieldSensorList(const FieldSensorList &sensorList,
423 const SoFieldList &fieldList) ;
424 void detachFieldSensorList(const FieldSensorList &sensorList) ;
425 static void fieldSensorCB(void *data, SoSensor *sensor) ;
426
427 // Indicate if the state is valid that is we are
428 // in a traversal
429 SbBool isStateValid() const
430 { return m_isStateValid ; }
431
432 // Add an element in the cache for caching
433 // Example of call : addElementCache(PoDomainElement::getClassStackIndex())
434 template<typename T>
435 void addElementCache()
436 {
437 if(isStateValid() && !isCacheValid())
438 m_cache->addElement(getState()->template getConstElement<T>());
439 }
440
441
442 // Remove all elements in a cache
443 // and rebuild it
444 void rebuildCache(SoCache **cache) ;
445
446 // Add all MeshViz used elements in all the cache
447 // to be sure that a modification of one the them
448 // will break the current cache
449 virtual void addElementsAllCaches() ;
450
451 // Indicate if the cache is rebuilt at each rebuild
452 // even if the cache is valid.
453 // That allows the user to manage the cache according to
454 // the value of some fields.
455 // FALSE by default
456 void setCacheAlwaysRebuild(SbBool flag)
457 { m_isCacheAlwaysRebuild = flag ; }
458 SbBool isCacheAlwaysRebuild() const
459 { return m_isCacheAlwaysRebuild ; }
460
461
462 // Indicate if the cache if valid
463 SbBool isCacheValid() const
464 { return m_isCacheValid ; }
465
466 // Vars
467 SoFieldList m_listFieldsChanged ;
468 SbBool needToStoreFieldsChanged ;
469
470 // Indicate if the state is valid (only during an action)
471 SbBool m_isStateValid ;
472
473 private:
474 // Vars
475 UpdateMethodType m_updateMethodType ;
476 SbBool m_hasBeenModified ;
477 SbBool m_isObjBuilt ;
478 SbBool m_isDomainTrans ;
479 SbBool m_isDomUseForRebuild ;
480 SbBool m_someFieldsHasChanged ;
481 PbDomain *m_domain, m_defaultDomain ;
482 SoCallbackCB *m_actionCallback ;
483
484 SbBool m_hasBeenBuilt ;
485
486 // Indicate if the cache is rebuilt at each rebuild
487 // even if the cache is valid.
488 // That allows the user to manage the cache according to
489 // the value of some fields.
490 SbBool m_isCacheAlwaysRebuild ;
491
492 // Current state (update for each action)
493 SoState *m_currentState ;
494
495 // Current cache for MeshViz elements
496 SoCache *m_cache ;
497
498 // Current cache for domain
499 SoCache *m_domainCache ;
500
501 // Indicate if the cache is valid
502 SbBool m_isCacheValid ;
503
504 // Store the current write action
505 SoWriteAction *m_currentWriteAction ;
506
507 PoRebuildCB *m_preRebuildCB, *m_postRebuildCB ;
508 void *m_preRebuildData, *m_postRebuildData ;
509
510 // Domain cache data
511 SbBox3f m_domainBoxCache;
512 PbDomain::TransformType m_domainTransformTypeCache;
513
514 // Static Vars
515 static NodeWriteFormat m_nodeWriteFormat ;
516 static TextType m_textType ;
517 static SbBool m_isVRML2Mode ;
518
519 // Methods
520 static void catchActionCB(void *, SoAction *) ;
521 static void catchActionLevel2CB(void *, SoAction *) ;
522
523 // Init/finish ref counter status
524 static int s_initRefCount;
525
526 static SbString s_soLdmValuationAction;
527} ;
528/*---------------------------------------------------------------------------*/
529
530#endif /* _PO_BASE_ */
531
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
void SoCallbackCB(void *userData, SoAction *action)
Callback functions registered with this node should be of this type.
Definition SoCallback.h:76
#define SO_KIT_CATALOG_ENTRY_HEADER(partName)
Definition SoSubKit.h:107
#define SO_KIT_ABSTRACT_HEADER(className)
Definition SoSubKit.h:95
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Abstract class for all b...
Definition PbBase.h:49
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Abstract class for data ...
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Class to define a domain...
Definition PbDomain.h:92
TransformType
Transform type.
Definition PbDomain.h:102
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Abstract base class for ...
Definition PoBase.h:74
void setUpdateMethod(UpdateMethodType type)
Sets scene graph update method.
Definition PoBase.h:143
TextType
Type of Text.
Definition PoBase.h:120
@ SO_ANNO_TEXT3
Definition PoBase.h:122
@ SO_TEXT3
Definition PoBase.h:121
virtual SbBool affectsState() const
See SoNode::affectsState() for explanations.
SbBool isBuilt() const
Indicates if the node kit has been built at least once.
Definition PoBase.h:197
static NodeWriteFormat getNodeWriteFormat()
Gets the node write format.
void addPreRebuildCallback(PoRebuildCB *cb, void *data)
Add a callback function to call when the node kit is rebuilt.
void setDomain(PbDomain *dom)
Sets a reference to a PbDomain object used to define the data limits of the graphics to be generated.
static void setTextType(TextType type)
Sets the type of text used.
void touchKit()
Indicates the node kit is modified.
static void setVRML2Mode(SbBool flag)
Set the VRML2 mode.
UpdateMethodType
Type of update method.
Definition PoBase.h:92
@ UPDATE_METHOD_IMMEDIATE
The kit is rebuilt immediately after each modification.
Definition PoBase.h:96
@ UPDATE_METHOD_ON_ACTION
The kit is rebuilt during a traversal (that is an action).
Definition PoBase.h:100
static void setNodeWriteFormat(NodeWriteFormat format)
Sets the node write format.
void removePreRebuildCallback(PoRebuildCB *cb, void *data=NULL)
Remove a callback function to call when the node kit is rebuilt.
void PoRebuildCB(void *userData, PoBase *base)
Definition PoBase.h:129
const PbDomain * getDomain() const
Gets a reference to a PbDomain object used to define the data limits of the graphics to be generated.
UpdateMethodType getUpdateMethod() const
Gets update method.
Definition PoBase.h:148
virtual SoNode * copy(SbBool copyConnections=FALSE) const
Copy method.
static TextType getTextType()
Gets the type of text used.
SbBool isModified() const
Return TRUE, if the kit has been modified, else otherwise.
Definition PoBase.h:192
void addPostRebuildCallback(PoRebuildCB *cb, void *data)
Add a callback function to call when the node kit is rebuilt.
NodeWriteFormat
Type of write format.
Definition PoBase.h:106
@ UNFOLD_NODE_WRITE_FORMAT
All MeshViz nodekits are written in an unfold format.
Definition PoBase.h:114
@ FOLD_NODE_WRITE_FORMAT
All MeshViz nodekits are written in a fold format.
Definition PoBase.h:110
static SbBool isVRML2Mode()
Gets the VRML2 mode (TRUE = VRML2 mode, FALSE Inventor mode)
void removePostRebuildCallback(PoRebuildCB *cb, void *data)
Remove a callback function to call when the node kit is rebuilt.
virtual void rebuild()
Forces the node kit to be rebuilt immediately.
Definition PoBase.h:211
3D box class.
Definition SbBox.h:649
virtual void truncate(int start)
Removes all pointers after one with given index, inclusive.
Definition SbPList.h:215
Class for smart character strings.
Definition SbString.h:202
Abstract base class for all actions.
Definition SoAction.h:132
Base class for all node kits.
Definition SoBaseKit.h:302
Style
Draw styles.
@ LINES
Draw only outlines (wireframe)
Abstract base class for objects that contain fields.
Base class for all fields.
Definition SoField.h:234
Maintains a list of pointers to fields.
Definition SoFieldList.h:72
Sensor class that can be attached to Open Inventor fields.
Renders a scene graph using Open Inventor's Render Engine.
Base class for all group nodes.
Definition SoGroup.h:122
Indexed polygonal face shape node.
Indexed polyline shape node.
Indexed triangle strip set shape node.
Model
Lighting model.
Polyline shape node.
Definition SoLineSet.h:190
Node that specifies how multiple materials are bound to shapes.
Surface material definition node.
Definition SoMaterial.h:186
Abstract base class for all database nodes.
Definition SoNode.h:145
Quadrilateral mesh shape node.
Definition SoQuadMesh.h:159
Abstract base class for Open Inventor sensors.
Definition SoSensor.h:97
Abstract base class for all shape nodes.
Definition SoShape.h:115
Traversal state.
Definition SoState.h:74
Writes a scene graph to a file.
int SbBool
Boolean type.
Definition SbBase.h:87