#include <attraggl.h>
Inheritance diagram for AttributeAgglomerator:
Public Member Functions | |
virtual | ~AttributeAgglomerator () |
BOOL | FindCommonAttributes (RenderableNodeEnumerator &Enumerator, CommonAttrMultiSet *const pCommonAttributeSet) |
At present, allows the Wizard Properties dialog to reflect whether attributes are applied to the selection or a node when no selection (the spread). | |
Static Public Attributes | |
static const UINT32 | MaxAttributes = 5000 |
Protected Member Functions | |
virtual AttributeIdentifier | GetAttributeType (NodeAttribute *const pAttrib) const =0 |
virtual BOOL | FindAppliedAttributes (Node *const pNode, CCUserAttrMap *const pAttribMap) const |
Searches attributes with non-NULL AttributeIdentifier's which are local to the given Node. | |
Private Member Functions | |
CC_DECLARE_MEMDUMP (AttributeAgglomerator) |
Definition at line 258 of file attraggl.h.
|
Definition at line 263 of file attraggl.h.
|
|
|
|
Searches attributes with non-NULL AttributeIdentifier's which are local to the given Node.
Definition at line 398 of file attraggl.cpp. 00399 { 00400 // Precondition checks 00401 ERROR2IF(pNode == NULL || pAttribMap == NULL, FALSE, "NULL Args"); 00402 00403 BOOL AttributesFound = FALSE; 00404 // Find the closest attribute applied to "this" node... 00405 NodeAttribute* pAttrib = NodeAttribute::FindFirstAppliedAttr(pNode); 00406 00407 // Repeat the following loop for all attributes we encounter in the tree. 00408 while (pAttrib != NULL && pAttrib->FindParent() == pNode) 00409 { 00410 // Get the run-time type of the attribute, which serves as a hash "key". 00411 AttributeIdentifier AttrID = GetAttributeType(pAttrib); 00412 00413 // if the AttrID is NULL we're not interested 00414 if (!AttrID.IsEmpty()) 00415 { 00416 // Check if this type is already in the hash table. If it isn't then insert 00417 // its address with its run-time type as the key, and check if we need to look 00418 // for any more. 00419 NodeAttribute* pDummy = NULL; 00420 if (!pAttribMap->Lookup(&AttrID, pDummy)) 00421 { 00422 // This is a new attribute for the map 00423 pAttribMap->SetAt(&AttrID, pAttrib); 00424 AttributesFound = TRUE; 00425 } 00426 else 00427 { 00428 ERROR3("AttributeAgglomerator::FindAppliedAttributes - Duplicate attribute found"); 00429 } 00430 } 00431 00432 // Go on to find the next attribute. 00433 pAttrib = NodeAttribute::FindPrevAppliedAttr(pAttrib); 00434 } 00435 00436 return AttributesFound; 00437 }
|
|
At present, allows the Wizard Properties dialog to reflect whether attributes are applied to the selection or a node when no selection (the spread).
AA_NONE: This case should not occur for the base class pAttr will be NULL AA_SINGLE: There is a single instance of the attribute in the iterator's set pAttr will point to it AA_COMMON: There is a common attribute pAttr will point to an instance of it AA_MANY: The attributes in the iterator's set have multiple values for the attribute class pAttr will be NULL
Definition at line 275 of file attraggl.cpp. 00277 { 00278 ERROR2IF(pCommonAttributeSet == NULL, FALSE, "NULL Args"); 00279 00280 BOOL Success = TRUE; 00281 00282 // For each object: 00283 // Build list of applied attributes 00284 // Lookup each item in the current set of common attributes 00285 // If not in set, add to set as single 00286 // If attribute in set 00287 // If set entry marked multiple ignore attribute 00288 // Otherwise compare values 00289 // If values differ, mark multiple 00290 // If values same, mark common 00291 00292 00293 // Initialise all CommonAttributeItems 00294 pCommonAttributeSet->ClearResults(); 00295 00296 // Create a map of Attribute types to applied attrs. This allows us to scan up the tree 00297 // looking for attributes applied to each object once only. 00298 CCUserAttrMap* const pAttrMap = new CCUserAttrMap; 00299 if (pAttrMap == NULL) 00300 { 00301 return FALSE; // out of memory 00302 } 00303 00304 // Scan all objects in the range, 00305 NodeRenderable* CurrentObject = Enumerator.FindFirst(); 00306 // Stop when we have found all attribute values (all ATTR_MANY), or there are no more objects 00307 // to process. 00308 while (CurrentObject != NULL && Success) 00309 { 00310 // Remove any items that may have been in the map 00311 pAttrMap->RemoveAll(); 00312 00313 // and build list of applied attributes 00314 FindAppliedAttributes(CurrentObject, pAttrMap); 00315 00316 // Lookup each item in the current set of common attributes 00317 NodePointer* pNodePointer = pAttrMap->FindFirst(); 00318 while (pNodePointer != NULL) 00319 { 00320 MultiCommonAttrItem* pCommonAttrItem = NULL; 00321 pCommonAttributeSet->Lookup(&(pNodePointer->GetAttrID()), pCommonAttrItem); 00322 00323 AttributeIdentifier AttrID(pNodePointer->GetAttrID()); 00324 NodeAttribute* const pCurrentObjectAttr = &(pNodePointer->GetNode()); 00325 // Was the attribute in the common attribute set? 00326 if (pCommonAttrItem == NULL) 00327 { 00328 // No, it's the first occurence of the attribute so mark it as single 00329 ERROR3IF(GetAttributeType(pCurrentObjectAttr) != AttrID, "GetAttributeType(pCurrentObjectAttr) != AttrID"); 00330 00331 pCommonAttributeSet->AddTypeToSet(AttrID, pCurrentObjectAttr); 00332 } 00333 else // entry in set exists 00334 { 00335 // If set entry marked multiple ignore attribute 00336 if (pCommonAttrItem->GetStatus() != MultiCommonAttrItem::AA_MANY) 00337 { 00338 // Otherwise compare values 00339 NodeAttribute* const pCommonAttribute = pCommonAttrItem->GetNode(); 00340 if (pCommonAttribute != NULL) 00341 { 00342 00343 if ((*pCurrentObjectAttr) == (*pCommonAttribute)) 00344 { 00345 // The attribute becomes a common attribute 00346 pCommonAttrItem->SetStatus(MultiCommonAttrItem::AA_COMMON); // up to this point anyway 00347 } 00348 else // If values differ, mark multiple 00349 { 00350 pCommonAttrItem->SetStatus(MultiCommonAttrItem::AA_MANY); 00351 // Hang on to an instance of the attribute so we can get a 00352 // description of it. 00353 } 00354 } 00355 else 00356 { 00357 ERROR3("CommonAttrItem->GetNode() == NULL"); 00358 } 00359 } // else ignore attribute 00360 } 00361 00362 pNodePointer = pAttrMap->FindNext(pNodePointer); 00363 00364 } // Attribute scan 00365 00366 // Get the next object 00367 CurrentObject = Enumerator.FindNext(CurrentObject); 00368 } // range scan 00369 00370 00371 delete pAttrMap; 00372 00373 return Success; 00374 }
|
|
Implemented in UserAttributeAgglomerator. |
|
Definition at line 267 of file attraggl.h. |