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-2014 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 00054 class SoMFFieldContainer : public SoMField { 00055 00056 // Use standard field stuff 00057 SO_MFIELD_REQUIRED_HEADER(SoMFFieldContainer); 00058 SO_MFIELD_CONSTRUCTOR_HEADER(SoMFFieldContainer); 00059 SO_MFIELD_VALUE_HEADER(SoMFFieldContainer, SoFieldContainer *, SoFieldContainer *); 00060 SO_MFIELD_SETVALUESPOINTER_HEADER(SoFieldContainer *); 00061 00065 void addFieldContainer(SoFieldContainer *fieldContainer); 00066 00071 void insertFieldContainer(SoFieldContainer *fieldContainer, int newFieldContainerIndex); 00072 00077 SoFieldContainer *getFieldContainer(int index) const; 00078 00082 int findFieldContainer(const SoFieldContainer *fieldContainer) const; 00083 00087 int getNumFieldContainers() const; 00088 00093 void removeFieldContainer(int index); 00094 00098 void removeFieldContainer(SoFieldContainer *fieldContainer) 00099 { removeFieldContainer(findFieldContainer(fieldContainer)); } 00100 00104 void removeAllFieldContainers(); 00105 00110 void replaceFieldContainer(int index, SoFieldContainer *newFieldContainer); 00111 00115 void replaceFieldContainer(SoFieldContainer *oldFieldContainer, SoFieldContainer *newFieldContainer) 00116 { replaceFieldContainer(findFieldContainer(oldFieldContainer), newFieldContainer); } 00117 00129 SoFieldContainer** startEditing(); 00130 00132 void finishEditing(); 00133 00134 private: 00135 static void initClass(); 00136 static void exitClass(); 00137 00138 // Update a copied field to use the copy of each fieldContainer if there is one 00139 virtual void fixCopy(SbBool copyConnections); 00140 00141 // Override this to also check the stored fieldContainers 00142 virtual SbBool referencesCopy() const; 00143 00144 private: 00145 // Override this to maintain write-references in fieldContainers 00146 virtual void countWriteRefs(SoOutput *out) const; 00147 00148 // Changes value in field without doing other notification stuff. 00149 // Keeps track of references and auditors. 00150 void setVal(int index, SoFieldContainer *newValue); 00151 00152 SoFieldContainer** m_oldValues; 00153 int m_oldNum; 00154 00155 }; 00156 00157 #endif // _SO_MF_FIELDCONTAINER_ 00158 00159 00160 00161 00162