#include <brushref.h>
Inheritance diagram for BrushRef:
Public Types | |
typedef std::list< BlendPathOffset > | list |
typedef list::iterator | iterator |
Public Member Functions | |
BrushRef () | |
Default constructor. | |
~BrushRef () | |
Default destructor. | |
BOOL | Initialise (NodeRenderableInk *pInitNode) |
This inits the BrushRef object with the given node. Essentially a wrapper for the blendref initialise function. However it also works out the blendpath offsets, if there are any. | |
BlendPathOffset * | GetFirstOffset (iterator *pHeadPosition) |
as above | |
BlendPathOffset * | GetNextOffset (iterator *pPosition) |
as above | |
iterator | GetEndPosition () |
DocRect | GetBoundingRect () |
as above, unions the bounding boxes | |
void | DeleteBitmapFills () |
Searches for bitmap fill attributes and deletes their bitmaps, see previous function for the rationale. Note that this function was designed to be called by the BrushDefinition destructor. I cannot think of a good reason for wanting to use it anywhere else. | |
void | DeleteAttributesAndPath () |
Goes through all of the blendpaths and sets a flag which ensures that all the applied attributes of this blendpath are deleted upon destruction. This must not be used under normal circumstances because these attributes will still be in use by other objects. It was designed for when we are blending brush attributes and have to generate our attribute maps from scratch. | |
void | FreeAttributes () |
Goes through the blendpaths and asks them to delete their cached attribute map. | |
void | TranslateTo (DocCoord Target) |
Translates the blendpaths and their applied attributes to Destination. | |
void | TransformAttributes (TransformBase &Trans) |
When a brush stroke is transformed in the document we do not really need to transform the blendpaths however we do need tot transform the attributes, otherwise bitmap fills become incorrect as do line widths etc. However if we transform all attributes then we also need to transform the blendpaths, because such things as radial fills are translated by the brush code from the position of the blendpaths. It is important however that we do not scale the blendpaths, as the scaling code assumes that they always stay the same size. | |
BOOL | MakeCopiesForRendering () |
Asks the blendpaths to make copies of their paths and attributes which we will use to render with. | |
BOOL | UpdateCopies () |
Asks the blendpaths to make copies of their paths and attributes which we will use to render with. | |
void | DeleteRenderCopies () |
Asks the blendpaths to delete the copies of paths and attributes. | |
Path * | GetFirstCopyPath () |
Makes the first blendpath our current blendpath member and returns the copy of its path. Basically you should use the system like this:. | |
Path * | GetNextCopyPath () |
Increments our current blendpath member and returns the copy path of the next blendpath. | |
CCAttrMap * | GetCurrentAttributeCopy () |
Protected Member Functions | |
BOOL | SetBitmapFillFlags () |
Because brush definitions exist independently of documents, but bitmap fills do not. Therefore if we make a brush with a bitmap fill and then delete them document we created it in we lose the fill. However the brush still exists, therefore this function searches for a bitmap fill attribute, and sets flags that tell the bitmap not to delete itself. NOTE: This means that we are responsible for deleting the bitmap fills that belong to us. | |
Protected Attributes | |
NodeRenderableInk * | m_pNode |
List | m_BlendPathList |
UINT32 | m_NumBlendPaths |
CMapPtrToPtr * | m_pBlendPathAttrMap |
DocRect | m_CachedRect |
list | m_OffsetList |
BlendPath * | m_pCurrentBlendPath |
Private Member Functions | |
CC_DECLARE_MEMDUMP (BrushRef) |
Definition at line 155 of file brushref.h.
|
Definition at line 161 of file brushref.h. |
|
Definition at line 160 of file brushref.h. |
|
Default constructor.
Definition at line 214 of file brushref.cpp. 00215 { 00216 m_pNode = NULL; 00217 m_NumBlendPaths = 0; 00218 m_pBlendPathAttrMap = NULL; 00219 m_CachedRect = DocRect(0,0,0,0); 00220 m_pCurrentBlendPath = NULL; 00221 }
|
|
Default destructor.
Definition at line 236 of file brushref.cpp. 00237 { 00238 FreeAttributes(); 00239 m_BlendPathList.DeleteAll(); 00240 m_OffsetList.clear(); 00241 }
|
|
|
|
Goes through all of the blendpaths and sets a flag which ensures that all the applied attributes of this blendpath are deleted upon destruction. This must not be used under normal circumstances because these attributes will still be in use by other objects. It was designed for when we are blending brush attributes and have to generate our attribute maps from scratch.
Definition at line 754 of file brushref.cpp. 00755 { 00756 // BlendPath* pLastPath = NULL; 00757 BlendPath* pBlendPath = GetFirstBlendPath(); 00758 while (pBlendPath != NULL) 00759 { 00760 // ensures that all the applied attributes will be deleted when the object is deleted 00761 pBlendPath->DeleteAttributesAndPath(); 00762 pBlendPath = GetNextBlendPath(pBlendPath); 00763 00764 } 00765 }
|
|
Searches for bitmap fill attributes and deletes their bitmaps, see previous function for the rationale. Note that this function was designed to be called by the BrushDefinition destructor. I cannot think of a good reason for wanting to use it anywhere else.
Definition at line 706 of file brushref.cpp. 00707 { 00708 // loop through each blendpath 00709 BlendPath* pBlendPath = GetFirstBlendPath(); 00710 00711 while (pBlendPath != NULL) 00712 { 00713 // retrieve the attribute node 00714 AttrBitmapFill* pBMPFill = pBlendPath->GetAppliedBitmapColourFill(); 00715 if (pBMPFill != NULL) 00716 { 00717 // get the attribute value 00718 BitmapFillAttribute* pVal = (BitmapFillAttribute*)pBMPFill->GetAttributeValue(); 00719 if (pVal != NULL) 00720 { 00721 // get the bitmap 00722 KernelBitmap* pBitmap = pVal->GetBitmap(); 00723 // if it has been flagged by us then zap it 00724 if (pBitmap != NULL && pBitmap->IsUsedByBrush()) 00725 { 00726 pBitmap->SetUsedByBrush(FALSE); 00727 pBitmap->Detach(); 00728 delete pBitmap; 00729 } 00730 } 00731 } 00732 pBlendPath = GetNextBlendPath(pBlendPath); 00733 } 00734 }
|
|
Asks the blendpaths to delete the copies of paths and attributes.
Definition at line 394 of file brushref.cpp. 00395 { 00396 // BlendPath* pLastPath = NULL; 00397 BlendPath* pBlendPath = GetFirstBlendPath(); 00398 while (pBlendPath != NULL) 00399 { 00400 pBlendPath->DeleteCopyPathAndAttributes(); 00401 pBlendPath = GetNextBlendPath(pBlendPath); 00402 00403 } 00404 }
|
|
Goes through the blendpaths and asks them to delete their cached attribute map.
Definition at line 780 of file brushref.cpp. 00781 { 00782 // BlendPath* pLastPath = NULL; 00783 BlendPath* pBlendPath = GetFirstBlendPath(); 00784 while (pBlendPath != NULL) 00785 { 00786 pBlendPath->SetFreeAttributeFlag(TRUE); 00787 pBlendPath = GetNextBlendPath(pBlendPath); 00788 00789 } 00790 //DeleteBitmapFills(); // disabled until I get it working properly 00791 }
|
|
as above, unions the bounding boxes
Reimplemented from BlendRef. Definition at line 571 of file brushref.cpp. 00572 { 00573 DocRect Rect; 00574 00575 BlendPath *pBlendPath = GetFirstBlendPath(); 00576 BlendPathOffset Offset; 00577 iterator ListPos = m_OffsetList.begin(); 00578 CCAttrMap *pAttrMap = NULL; 00579 while (pBlendPath != NULL) 00580 { 00581 DocRect PathRect; 00582 pAttrMap = pBlendPath->FindAppliedAttributes(); 00583 pBlendPath->m_pPath->GetTrueBoundingRect(&PathRect, 0, pAttrMap); 00584 if (ListPos != m_OffsetList.end() ) 00585 { 00586 Offset = *ListPos++; 00587 /* PathRect.hix += Offset.m_XOffset; 00588 PathRect.lox += Offset.m_XOffset; 00589 PathRect.hiy += Offset.m_YOffset; 00590 PathRect.loy += Offset.m_YOffset; 00591 */ 00592 } 00593 Rect = Rect.Union(PathRect); 00594 pAttrMap = NULL; 00595 pBlendPath = GetNextBlendPath(pBlendPath); 00596 } 00597 00598 return Rect; 00599 }
|
|
Definition at line 498 of file brushref.cpp. 00499 { 00500 if (m_pCurrentBlendPath == NULL) 00501 { 00502 ERROR3("Current blendpath is NULL in BrushRef::GetCurrentAttributeCopy"); 00503 return NULL; 00504 } 00505 return m_pCurrentBlendPath->GetCopyAttributes(); 00506 00507 }
|
|
Definition at line 170 of file brushref.h. 00170 { return m_OffsetList.end(); }
|
|
Makes the first blendpath our current blendpath member and returns the copy of its path. Basically you should use the system like this:.
while (pPath) { pMap = pBrushRef->GetCurrentAttributeCopy(); pMap->Render(or whatever) pPath->Render (or whatever) pPath = pBrushRef->GetNextCopyPath(); } Definition at line 438 of file brushref.cpp. 00439 { 00440 m_pCurrentBlendPath = GetFirstBlendPath(); 00441 if (m_pCurrentBlendPath == NULL) 00442 { 00443 ERROR3("First blendpath is NULL in BrushRef::GetFirstCopyPath"); 00444 return NULL; 00445 } 00446 return m_pCurrentBlendPath->GetCopyPath(); 00447 }
|
|
as above
Definition at line 523 of file brushref.cpp. 00524 { 00525 if (m_OffsetList.empty()) 00526 return NULL; 00527 else 00528 { 00529 *pHeadPosition = m_OffsetList.begin(); 00530 return &( *(*pHeadPosition)++ ); 00531 } 00532 }
|
|
Increments our current blendpath member and returns the copy path of the next blendpath.
Definition at line 465 of file brushref.cpp. 00466 { 00467 // If our current blendpath isn't set yet then its an error 00468 if (m_pCurrentBlendPath == NULL) 00469 { 00470 ERROR3("Current blendpath is NULL in BrushRef::GetNextCopyPath"); 00471 return NULL; 00472 } 00473 m_pCurrentBlendPath = GetNextBlendPath(m_pCurrentBlendPath); 00474 00475 if (m_pCurrentBlendPath != NULL) 00476 return m_pCurrentBlendPath->GetCopyPath(); 00477 00478 // we've hit the end of the line 00479 return NULL; 00480 }
|
|
as above
Definition at line 549 of file brushref.cpp. 00550 { 00551 if( m_OffsetList.empty() ) 00552 return NULL; 00553 else 00554 return &( *(*pHeadPosition)++ ); 00555 }
|
|
This inits the BrushRef object with the given node. Essentially a wrapper for the blendref initialise function. However it also works out the blendpath offsets, if there are any.
Definition at line 259 of file brushref.cpp. 00260 { 00261 ERROR2IF(pInitNode == NULL, FALSE, "Ink node is NULL in BrushRef::Initialise"); 00262 00263 // Note that BrushDefinition::GenerateBrush now prevents objects with brush attributes being 00264 // used to generate brushes, instead it converts them to groups of nodepaths as per Convert Line to Shapes 00265 00266 pInitNode->MakeAttributeComplete(); // just in case we're missing any 00267 00268 BOOL ok = BlendRef::InitialiseForBrush(pInitNode); 00269 00270 if (ok) 00271 { 00272 // if we have made a brushref from a group then the different 00273 // blendpaths will be offset from the centre of. work out these 00274 // offsets and store them in a list 00275 m_OffsetList.clear(); 00276 DocRect BRect = GetBoundingRect(); 00277 DocCoord Centre = BRect.Centre(); 00278 00279 BlendPath* pBlendPath = GetFirstBlendPath(); 00280 00281 while (pBlendPath != NULL) 00282 { 00283 Path* pPath = pBlendPath->GetPath(); 00284 if (pPath) 00285 { 00286 DocRect BlendPathRect = pPath->GetBoundingRect(); 00287 DocCoord BlendPathCentre = BlendPathRect.Centre(); 00288 00289 BlendPathOffset ThisOffset; 00290 ThisOffset.m_XOffset = BlendPathCentre.x - Centre.x ; 00291 ThisOffset.m_YOffset = BlendPathCentre.y - Centre.y; 00292 ThisOffset.CalculateAngleAndMagnitude(); 00293 m_OffsetList.push_back(ThisOffset); 00294 pBlendPath->FindAppliedAttributes(); 00295 pBlendPath = GetNextBlendPath(pBlendPath); 00296 } 00297 else 00298 { 00299 ERROR3("BlendPath has no path"); 00300 return FALSE; 00301 } 00302 } 00303 // if we have a bitmap fill we need to do some special things.. 00304 SetBitmapFillFlags(); 00305 PreBlend(); 00306 if (pInitNode->IsABlend()) 00307 ((NodeBlend*)pInitNode)->Deinit(); 00308 return TRUE; 00309 } 00310 00311 00312 return FALSE; 00313 00314 }
|
|
Asks the blendpaths to make copies of their paths and attributes which we will use to render with.
Definition at line 332 of file brushref.cpp. 00333 { 00334 // BlendPath* pLastPath = NULL; 00335 BlendPath* pBlendPath = GetFirstBlendPath(); 00336 BOOL ok = TRUE; 00337 while (pBlendPath != NULL) 00338 { 00339 if (ok) 00340 ok = pBlendPath->MakeCopyPathAndAttributes(); 00341 pBlendPath = GetNextBlendPath(pBlendPath); 00342 00343 } 00344 return ok; 00345 00346 }
|
|
Because brush definitions exist independently of documents, but bitmap fills do not. Therefore if we make a brush with a bitmap fill and then delete them document we created it in we lose the fill. However the brush still exists, therefore this function searches for a bitmap fill attribute, and sets flags that tell the bitmap not to delete itself. NOTE: This means that we are responsible for deleting the bitmap fills that belong to us.
Definition at line 619 of file brushref.cpp. 00620 { 00621 // for each blendpath we wish to find out if they have an applied bitmap fill attribute. 00622 // if so then we want to copy it, and replace it in the attribute map 00623 BlendPath* pBlendPath = GetFirstBlendPath(); 00624 00625 while (pBlendPath != NULL) 00626 { 00627 // there may be both a colour fill and transparency attribute, so get both 00628 AttrBitmapFill* pBMPFill = pBlendPath->GetAppliedBitmapColourFill(); 00629 if (pBMPFill != NULL) 00630 { 00631 // Get the attribute value 00632 BitmapFillAttribute* pVal = (BitmapFillAttribute*)pBMPFill->GetAttributeValue(); 00633 00634 if (pVal == NULL) 00635 { 00636 ERROR3("Couldn't retrieve attribute value"); 00637 return FALSE; 00638 } 00639 00640 KernelBitmap* pKBitmap = pVal->GetBitmap(); 00641 if (pKBitmap != NULL) 00642 { 00643 OILBitmap* pOBitmap = pKBitmap->GetActualBitmap(); 00644 00645 // tell the bitmaps that they are being used by us so that if the 00646 // document closes they don't get deleted 00647 if (pOBitmap != NULL) 00648 { 00649 pOBitmap->SetUsedByBrush(TRUE); 00650 pKBitmap->SetUsedByBrush(TRUE); 00651 } 00652 00653 } 00654 } 00655 00656 AttrBitmapFill* pTranspFill = pBlendPath->GetAppliedBitmapTranspFill(); 00657 if (pTranspFill != NULL) 00658 { 00659 // Get the attribute value 00660 BitmapFillAttribute* pVal = (BitmapFillAttribute*)pTranspFill->GetAttributeValue(); 00661 00662 if (pVal == NULL) 00663 { 00664 ERROR3("Couldn't retrieve attribute value"); 00665 return FALSE; 00666 } 00667 00668 KernelBitmap* pKBitmap = pVal->GetBitmap(); 00669 if (pKBitmap != NULL) 00670 { 00671 OILBitmap* pOBitmap = pKBitmap->GetActualBitmap(); 00672 00673 // tell the bitmaps that they are being used by us so that if the 00674 // document closes they don't get deleted 00675 if (pOBitmap != NULL) 00676 { 00677 pOBitmap->SetUsedByBrush(TRUE); 00678 pKBitmap->SetUsedByBrush(TRUE); 00679 } 00680 00681 } 00682 } 00683 00684 pBlendPath = GetNextBlendPath(pBlendPath); 00685 } 00686 return TRUE; 00687 }
|
|
When a brush stroke is transformed in the document we do not really need to transform the blendpaths however we do need tot transform the attributes, otherwise bitmap fills become incorrect as do line widths etc. However if we transform all attributes then we also need to transform the blendpaths, because such things as radial fills are translated by the brush code from the position of the blendpaths. It is important however that we do not scale the blendpaths, as the scaling code assumes that they always stay the same size.
Definition at line 861 of file brushref.cpp. 00862 { 00863 BlendPath *pBlendPath = GetFirstBlendPath(); 00864 CCAttrMap *pAttrMap = NULL; 00865 00866 CCRuntimeClass *pType; 00867 void *pVal; 00868 NodeAttribute *pNodeAttr; 00869 00870 while (pBlendPath != NULL) 00871 { 00872 // we want to transform attributes too 00873 pAttrMap = pBlendPath->FindAppliedAttributes(); 00874 if (pAttrMap == NULL) 00875 { 00876 ERROR3("No applied attributes"); 00877 } 00878 else 00879 { 00880 // monster bodge - currently we only actually want to transform line widths and bitmap fills 00881 for( CCAttrMap::iterator Pos = pAttrMap->GetStartPosition(); Pos != pAttrMap->GetEndPosition(); ) 00882 { 00883 // Get attr at position Pos 00884 pAttrMap->GetNextAssoc( Pos, pType, pVal ); 00885 00886 // pVal is actually an attribute, so get a ptr to it and render it 00887 pNodeAttr = (NodeAttribute *)pVal; 00888 00889 if (pNodeAttr->IsABitmapFill()) 00890 pNodeAttr->Transform(Trans); 00891 00892 if( pNodeAttr->IsALineWidthAttr() && FALSE != Trans.TransLines ) 00893 { 00894 INT32 Test = labs( INT32(Trans.GetScalar().MakeDouble() * ((AttrLineWidth*)pNodeAttr)->Value.LineWidth) ); 00895 if (Test >= 10) 00896 pNodeAttr->Transform(Trans); 00897 } 00898 00899 00900 } 00901 00902 pAttrMap = NULL; 00903 } 00904 00905 pBlendPath = GetNextBlendPath(pBlendPath); 00906 } 00907 return; 00908 }
|
|
Translates the blendpaths and their applied attributes to Destination.
Definition at line 806 of file brushref.cpp. 00807 { 00808 BlendPath* pBlendPath = GetFirstBlendPath(); 00809 CCAttrMap* pAttrMap = NULL; 00810 DocRect BRect; 00811 DocCoord CurrentCentre; 00812 Trans2DMatrix Trans; 00813 00814 while (pBlendPath != NULL) 00815 { 00816 // find out where we are 00817 BRect = pBlendPath->m_pPath->GetBoundingRect(); 00818 CurrentCentre = BRect.Centre(); 00819 00820 // set the translation in the matrix 00821 Trans.SetTransform(Destination.x - CurrentCentre.x, Destination.y - CurrentCentre.y); 00822 00823 // we want to transform attributes too 00824 pAttrMap = pBlendPath->FindAppliedAttributes(); 00825 if (pAttrMap == NULL) 00826 { 00827 ERROR3("No applied attributes"); 00828 } 00829 else 00830 { 00831 pAttrMap->Transform(Trans); 00832 pAttrMap = NULL; 00833 } 00834 pBlendPath->Transform(Trans); 00835 00836 pBlendPath = GetNextBlendPath(pBlendPath); 00837 } 00838 }
|
|
Asks the blendpaths to make copies of their paths and attributes which we will use to render with.
Definition at line 364 of file brushref.cpp. 00365 { 00366 // BlendPath* pLastPath = NULL; 00367 BlendPath* pBlendPath = GetFirstBlendPath(); 00368 BOOL ok = TRUE; 00369 while (pBlendPath != NULL && ok) 00370 { 00371 pBlendPath->UpdateCopyPathAndAttributes(); 00372 pBlendPath = GetNextBlendPath(pBlendPath); 00373 00374 } 00375 return ok; 00376 00377 }
|
|
Reimplemented from BlendRef. Definition at line 197 of file brushref.h. |
|
Definition at line 200 of file brushref.h. |
|
Reimplemented from BlendRef. Definition at line 198 of file brushref.h. |
|
Definition at line 203 of file brushref.h. |
|
Reimplemented from BlendRef. Definition at line 199 of file brushref.h. |
|
Definition at line 206 of file brushref.h. |
|
Reimplemented from BlendRef. Definition at line 196 of file brushref.h. |