|
Katana Plug-in APIs 0.1
|
00001 // Copyright (c) 2017 The Foundry Visionmongers Ltd. All Rights Reserved. 00002 00003 #ifndef FNVIEWER_LOCATIONEVENT_H 00004 #define FNVIEWER_LOCATIONEVENT_H 00005 00006 #include <FnAttribute/FnAttribute.h> 00007 #include <FnViewer/suite/FnViewerDelegateSuite.h> 00008 00009 #include <string> 00010 00011 namespace Foundry 00012 { 00013 namespace Katana 00014 { 00015 namespace ViewerAPI 00016 { 00017 00024 struct ViewerLocationStateChanges 00025 { 00029 ViewerLocationStateChanges() : 00030 locationRemoved(false), 00031 attributesUpdated(false), 00032 localXformUpdated(false), 00033 excludedChanged(false), 00034 descendantsHiddenChanged(false) {} 00035 00043 explicit ViewerLocationStateChanges(FnViewerLocationEventBitField flags) 00044 { 00045 parseBitfield(flags); 00046 } 00047 00048 private: 00049 FnViewerLocationEventBitField writeBitfield() const 00050 { 00051 FnViewerLocationEventBitField flags = 0; 00052 if (locationRemoved) 00053 { 00054 flags |= kFnViewerLocationEvent_locationRemoved; 00055 } 00056 if (attributesUpdated) 00057 { 00058 flags |= kFnViewerLocationEvent_attributesUpdated; 00059 } 00060 if (localXformUpdated) 00061 { 00062 flags |= kFnViewerLocationEvent_localXformUpdated; 00063 } 00064 if (excludedChanged) 00065 { 00066 flags |= kFnViewerLocationEvent_excludedChanged; 00067 } 00068 if (descendantsHiddenChanged) 00069 { 00070 flags |= kFnViewerLocationEvent_descendantsHiddenChanged; 00071 } 00072 return flags; 00073 } 00074 00075 void parseBitfield(FnViewerLocationEventBitField flags) 00076 { 00077 locationRemoved = flags & kFnViewerLocationEvent_locationRemoved; 00078 attributesUpdated = flags & kFnViewerLocationEvent_attributesUpdated; 00079 localXformUpdated = flags & kFnViewerLocationEvent_localXformUpdated; 00080 excludedChanged = flags & kFnViewerLocationEvent_excludedChanged; 00081 descendantsHiddenChanged = flags & 00082 kFnViewerLocationEvent_descendantsHiddenChanged; 00083 } 00084 00085 public: 00088 bool locationRemoved; 00089 00093 bool attributesUpdated; 00094 00097 bool localXformUpdated; 00098 00100 bool excludedChanged; 00101 00103 bool descendantsHiddenChanged; 00104 00105 // @cond FN_INTERNAL_DEV 00106 friend struct ViewerLocationEvent; 00107 // @endcond 00108 }; 00109 00111 struct ViewerLocationEvent 00112 { 00116 ViewerLocationEvent() 00117 : localXformIsAbsolute(false), 00118 excluded(false), 00119 descendantsHidden(false), 00120 isVirtualLocation(false) {} 00121 00128 explicit ViewerLocationEvent(const FnViewerLocationEventStruct& cStruct) 00129 : locationPath(cStruct.locationPath), 00130 attributes(FnAttribute::Attribute::CreateAndRetain(cStruct.attributes)), 00131 localXformMatrix( 00132 FnAttribute::Attribute::CreateAndRetain(cStruct.localXformMatrix)) 00133 { 00134 parseBitfield(cStruct.flags); 00135 } 00136 00141 FnViewerLocationEventStruct getCStruct() const 00142 { 00143 FnViewerLocationEventStruct event; 00144 event.locationPath = locationPath.c_str(); 00145 event.attributes = attributes.getHandle(); 00146 event.localXformMatrix = localXformMatrix.getHandle(); 00147 event.flags = writeBitfield(); 00148 return event; 00149 } 00150 00151 private: 00152 FnViewerLocationEventBitField writeBitfield() const 00153 { 00154 FnViewerLocationEventBitField flags = 0; 00155 00156 if (localXformIsAbsolute) 00157 { 00158 flags |= kFnViewerLocationEvent_localXformIsAbsolute; 00159 } 00160 if (excluded) 00161 { 00162 flags |= kFnViewerLocationEvent_excluded; 00163 } 00164 if (descendantsHidden) 00165 { 00166 flags |= kFnViewerLocationEvent_descendantsHidden; 00167 } 00168 if (isVirtualLocation) 00169 { 00170 flags |= kFnViewerLocationEvent_isVirtualLocation; 00171 } 00172 00173 flags |= stateChanges.writeBitfield(); 00174 00175 return flags; 00176 } 00177 00178 void parseBitfield(FnViewerLocationEventBitField flags) 00179 { 00180 localXformIsAbsolute = flags & 00181 kFnViewerLocationEvent_localXformIsAbsolute; 00182 excluded = flags & kFnViewerLocationEvent_excluded; 00183 descendantsHidden = flags & kFnViewerLocationEvent_descendantsHidden; 00184 isVirtualLocation = flags & kFnViewerLocationEvent_isVirtualLocation; 00185 00186 stateChanges.parseBitfield(flags); 00187 } 00188 00189 public: 00191 std::string locationPath; 00192 00194 FnAttribute::GroupAttribute attributes; 00195 00199 FnAttribute::DoubleAttribute localXformMatrix; 00200 00205 bool localXformIsAbsolute; 00206 00211 bool excluded; 00212 00221 bool descendantsHidden; 00222 00227 bool isVirtualLocation; 00228 00230 ViewerLocationStateChanges stateChanges; 00231 }; 00232 00235 } // namespace ViewerAPI 00236 } // namespace Katana 00237 } // namespace Foundry 00238 00239 #endif
1.7.3