00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : Nicolas DAGUISE (MMM yyyy) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef _SO_MF_FIELDCONTAINER_ 00026 #define _SO_MF_FIELDCONTAINER_ 00027 00028 class SoFieldContainer; 00029 00030 #include <Inventor/fields/SoSubField.h> 00031 00033 // 00034 // SoMFFieldContainer subclass of SoMField. Each field value is a pointer to an 00035 // SoFieldContainer. The field automatically maintains references to the 00036 // fieldContainers it points to and propagates notification from the 00037 // fieldContainers. 00038 // 00040 00055 class SoMFFieldContainer : public SoMField { 00056 00057 // Use standard field stuff 00058 SO_MFIELD_REQUIRED_HEADER(SoMFFieldContainer); 00059 SO_MFIELD_CONSTRUCTOR_HEADER(SoMFFieldContainer); 00060 SO_MFIELD_VALUE_HEADER(SoMFFieldContainer, SoFieldContainer *, SoFieldContainer *); 00061 SO_MFIELD_SETVALUESPOINTER_HEADER(SoFieldContainer *); 00062 00066 void addFieldContainer(SoFieldContainer *fieldContainer); 00067 00072 void insertFieldContainer(SoFieldContainer *fieldContainer, int newFieldContainerIndex); 00073 00078 SoFieldContainer *getFieldContainer(int index) const; 00079 00083 int findFieldContainer(const SoFieldContainer *fieldContainer) const; 00084 00088 int getNumFieldContainers() const; 00089 00094 void removeFieldContainer(int index); 00095 00099 void removeFieldContainer(SoFieldContainer *fieldContainer) 00100 { removeFieldContainer(findFieldContainer(fieldContainer)); } 00101 00105 void removeAllFieldContainers(); 00106 00111 void replaceFieldContainer(int index, SoFieldContainer *newFieldContainer); 00112 00116 void replaceFieldContainer(SoFieldContainer *oldFieldContainer, SoFieldContainer *newFieldContainer) 00117 { replaceFieldContainer(findFieldContainer(oldFieldContainer), newFieldContainer); } 00118 00130 SoFieldContainer** startEditing(); 00131 00133 void finishEditing(); 00134 00135 private: 00136 static void initClass(); 00137 static void exitClass(); 00138 00139 // Update a copied field to use the copy of each fieldContainer if there is one 00140 virtual void fixCopy(SbBool copyConnections); 00141 00142 // Override this to also check the stored fieldContainers 00143 virtual SbBool referencesCopy() const; 00144 00145 private: 00146 // Override this to maintain write-references in fieldContainers 00147 virtual void countWriteRefs(SoOutput *out) const; 00148 00149 // Changes value in field without doing other notification stuff. 00150 // Keeps track of references and auditors. 00151 void setVal(int index, SoFieldContainer *newValue); 00152 00153 SoFieldContainer** m_oldValues; 00154 int m_oldNum; 00155 00156 }; 00157 00158 #endif // _SO_MF_FIELDCONTAINER_ 00159 00160 00161 00162 00163