NodeRenderableBounded Class Reference

As NodeRenderable, but with a bounding box describing the area this object occupies. This class also includes functions for use with attribute optimisation. More...

#include <node.h>

Inheritance diagram for NodeRenderableBounded:

NodeRenderable Node CCObject SimpleCCObject NodeBevelBegin NodeRenderableInk NodeRenderablePaper BaseTextClass NodeBevel NodeBlender NodeBrushMaker NodeClipView NodeCompound NodeContour NodeGuideline NodeMouldBitmap NodePath NodeRegularShape NodeSimpleShape Chapter Layer NodeDocument NodeGrid Page Spread List of all members.

Public Member Functions

 NodeRenderableBounded ()
 Default constructor.
 NodeRenderableBounded (Node *ContextNode, AttachNodeDirection Direction, BOOL Locked=FALSE, BOOL Mangled=FALSE, BOOL Marked=FALSE, BOOL Selected=FALSE)
 This method initialises the node and links it to ContextNode in the direction specified by Direction. All necessary tree links are updated.
 ~NodeRenderableBounded ()
 Since this node is dieing make sure that any cached data associated with it is also removed...
virtual void GetDebugDetails (StringBase *Str)
 For obtaining debug information about the Node.
virtual SubtreeRenderState RenderSubtree (RenderRegion *pRender, Node **ppNextNode=NULL, BOOL bClip=TRUE)
 Virtual function - this function will indicate to the caller whether or not we want to render the given node, according to the information passed in.
virtual void Transform (TransformBase &)
 Base class transform function.
virtual void TransformChildren (TransformBase &)
 Transforms the Child nodes of this node. This allows fills etc to move with the objects.
virtual void PolyCopyNodeContents (NodeRenderable *pNodeCopy)
 Polymorphically copies the contents of this node to another.
virtual BOOL CanTakeAttributeType (CCRuntimeClass *)
 This function will return TRUE when called on NodeRenderableBounded nodes and those derived from it. Determine whether or not a bounded node can take a particular kind of attribute. This is used for various objects, e.g. bitmap objects use it to accept transparent fill geometries but not normal ones, because they are always filled with the bitmap. Base class version always returns TRUE so by default an object supports all attribute types.
void ValidateBoundingRect ()
 Marks this nodes bounding rect as valid again. You should not generally speaking be using this function. It was created so that new nodes could be sure of invalidating their parents bounding rects. DoInsertNewNode() is the only real case in which it can be used without express written permission from the UN.
virtual void InvalidateBoundingRect (BOOL InvalidateChildBounds=FALSE)
 Marks the bounding rect of this node as invalid, as well as marking this nodes parents as invalid as well. Next time a nodes GetBoundingRect() function is called the bounding rect will be recalculated if needed.
virtual DocRect GetBoundingRect (BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE)
 returns the nodes bounding rectangle. If the rectangle is valid the rectangle is simply returned, but is IsBoundingRectValid is FALSE (cos someone called InvaldateBoundingRect() on this node, or one of its children) then the bounding rect is first calculated and the flag reset, before it is returned. This is the base class version of this function and will build a bounding box out of the union of the nodes childrens bounding boxes. Your node MUST replace this function if this is not what you want it to do....
virtual DocRect GetUnionBlobBoundingRect (BOOL bIncludeEffects=TRUE)
 This simply returns the result of GetBlobBoundingRect() as the default action for the base class.
virtual DocRect GetEorDragBoundingRect ()
virtual DocRect GetImagemapClickableRectangle ()
virtual DocRect GetEffectStackBounds (BOOL *pbFoundEffects=NULL)
 Find the bounds of any effects which might be affected by changes to this node.
virtual void IncludeChildrensBoundingRects (DocRect *)
 The child attribute Blob bounding rects are included in the BoundingRect. Note: re-written by Ed 25/4/95 Now only includes bounds of child attrs (rather than all NodeRenderableBounded) The assumption is that no child can be selected if it's parent is, so attr blobs of child nodes cannot be visible at the same time as their parents!
BOOL IsIntersectedWith (DocRect *pClipRect)
 Determine if this node is intersected with the rectangle supplied.
virtual BOOL IsBounded () const
virtual BOOL Snap (DocCoord *pDocCoord)
 ALWAYS RETURNS FALSE! This is just a virtual base function intended to be overridden.
virtual BOOL Snap (DocRect *pDocRect, const DocCoord &PrevCoord, const DocCoord &CurCoord)
 ALWAYS RETURNS FALSE! This is just a virtual base function intended to be overridden. Scope: public.
virtual BOOL SnapToCoords (DocCoord *pDocCoord)
 This is a form of Magnetic snapping. It Snaps the Coordinates to the Significant points around a shape. eg. It would snap to the EndPoints along a path, the centre and corners of a rectangle etc. This snapping is more powerful than the normal magnetic snapping, so that these significant points can be snapped to more easily. This is the base class version of the function and does no snapping at all. It always returns FALSE. If you want your node to make use of this sort of snapping, override this function and use the MagneticPointRadius to decide if the DocCoord is close enough to be snapped.
virtual BOOL IsMagnetic ()
 Returns that magnetic state of this node Scope: public.
virtual void SetMagneticState (BOOL state)
 Allows you to set the magnetic state of this node Scope: public.
virtual double GetRotationAngle ()
 Call this function to obtain the current angle of rotation of the node. By default this is zero. Nodes derived from NodeRenderableBounded should override this function and return the angle of rotation using their own particular method Scope: public.
virtual BOOL RenderCached (RenderRegion *pRender)
 Protected Helper function Allow this node to render itself using cached data if it has it and for that cached data to represent an arbitrary section of the document (usually a subtree but can be more).
virtual BOOL CaptureCached (RenderRegion *pRender)
 Protected Helper function Use the CaptureManager to capture the results of rendering, cache them and associate them with this Ink node.
virtual BOOL ReleaseCached (BOOL bAndParents=TRUE, BOOL bAndChildren=TRUE, BOOL bSelf=TRUE, BOOL bAndDerived=TRUE)
 Protected Helper function Use the CaptureManager to capture the results of rendering, cache them and associate them with this Ink node.
virtual void CopyCached (NodeRenderableBounded *pCopyOfNode, double dRes, INT32 maxOption=0)
 Copy fixed res cached bitmaps associated with this node to be associated with the specified new node.
virtual void CopyCached (NodeRenderableBounded *pCopyOfNode)
 Copy all cached bitmaps associated with this node to be associated with the specified new node.
virtual void TransformCached (TransformBase &Trans, double dTestPixelWidth)
 Transform all the cached bitmaps associated with this node.
virtual BOOL HasCachedDirectBitmap ()
BOOL ContainsNonMixTransparency (RenderRegion *pRegion)
 Find out whether this node's subtree contains non-mix transparency. Useful for optimising cacheing because while you want things to be cached as 32BPP RGBT bitmaps most of the time, non-mix transparencies can't be captured that way and so some work ahs to be done to transform down to a 24BPP RGB bitmap - better to avoid that by calling this function.
virtual void RenderEffectAttributes (RenderRegion *pRegion)
 Render any effect attributes attached to this node.
virtual BOOL IsDifferent (Node *pOther)
 Determine if 2 nodes are considered different.
virtual DocCoord FindExtendCentre ()
virtual DocRect GetExtendTargetBounds (const ExtendParams &ExtParams)
 Return a DocRect which contains the bounds of this node as defined and required by the Extending mechanism.

Static Public Member Functions

static BOOL Init ()
 Declare the preferences for the magnetic options. Now also declares the layers section rather than having a new explicit init in the layers section.

Static Public Attributes

static INT32 MagneticPointRadius = 750*6
 This is the radius around a control point (such as the corner of a rectangle, or the end point in the middle of a path) that will allow other points to be magnetically attracted to it. This is measured in millipoints.
static INT32 MagneticLineRadius = 750*4
 This is the radius around a path (such as the edges of a rectangle, or the whole of a path) that will allow other points to be magnetically attracted to it. This is measured in millipoints.
static BOOL bEnableCacheing = TRUE
 Enable or disable bitmap cacheing of parts of the tree during GRenderRegion rendering.
static BOOL bThrottleCacheing = TRUE
 TRUE - Throttle cacheing to be 5% of total rendering time or less.
static BOOL bShowCacheBlobs = FALSE
 TRUE - Show special markers when cached groups are selected.

Protected Member Functions

BOOL IsMagneticallyClose (DocCoord *, DocCoord *)
 Tests to see if the 2 coordinates are close enough together to qualify as Magnetically close to each other. If they are, then pOriginalCoord is Modified to match pTestCoord and TRUE id returned. If not, then all the coords are left alone and FALSE is returned.
virtual NodeSimpleCopy ()
 This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes.
void CopyNodeContents (NodeRenderableBounded *NodeCopy)
 This method copies the node's contents to the node pointed to by NodeCopy.

Protected Attributes

BOOL IsBoundingRectValid
DocRect BoundingRectangle
BOOL Magnetic
BOOL MayBeCached

Private Member Functions

void InvalidateBoundingRectHelper ()
 Marks the bounding rect of this node as invalid, as well as marking this nodes parents as invalid as well. Next time a nodes GetBoundingRect() function is called the bounding rect will be recalculated if needed.

Detailed Description

As NodeRenderable, but with a bounding box describing the area this object occupies. This class also includes functions for use with attribute optimisation.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/04/94
See also:
NodeRendereable

Definition at line 1317 of file node.h.


Constructor & Destructor Documentation

NodeRenderableBounded::NodeRenderableBounded  ) 
 

Default constructor.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/04/94

Definition at line 1134 of file noderend.cpp.

01134                                             :NodeRenderable()   
01135 {     
01136     IsBoundingRectValid = FALSE;
01137     Magnetic            = FALSE;
01138     MayBeCached         = FALSE;    // Definitely not cached
01139 }

NodeRenderableBounded::NodeRenderableBounded Node ContextNode,
AttachNodeDirection  Direction,
BOOL  Locked = FALSE,
BOOL  Mangled = FALSE,
BOOL  Marked = FALSE,
BOOL  Selected = FALSE
 

This method initialises the node and links it to ContextNode in the direction specified by Direction. All necessary tree links are updated.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/4/93
Parameters:
ContextNode,: Pointer to a node which this node is to be attached to. [INPUTS] Direction: Specifies the direction in which the node is to be attached to the ContextNode. The values this variable can take are as follows: PREV : Attach node as a previous sibling of the context node NEXT : Attach node as a next sibling of the context node FIRSTCHILD: Attach node as the first child of the context node LASTCHILD : Attach node as a last child of the context node The remaining inputs specify the status of the node: Locked: Is node locked ? Mangled: Is node mangled ? Marked: Is node marked ? Selected: Is node selected ?
Returns:
Errors: An assertion error will occur if ContextNode is NULL

Definition at line 1169 of file noderend.cpp.

01171                : NodeRenderable(ContextNode, Direction, Locked, Mangled, Marked, Selected)
01172 {                         
01173     IsBoundingRectValid = FALSE;
01174     Magnetic            = FALSE;
01175     Dragged             = FALSE;
01176     MayBeCached         = FALSE;    // Definitely not cached
01177 }

NodeRenderableBounded::~NodeRenderableBounded  ) 
 

Since this node is dieing make sure that any cached data associated with it is also removed...

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/06/2004
Parameters:
- [INPUTS]
[OUTPUTS] 
Returns:
-

Errors:

Definition at line 1197 of file noderend.cpp.

01198 {
01199     if (MayBeCached)
01200     {
01201         // There could be some cached bitmaps associated with this node
01202         CBitmapCacheKey mykey(this, 42);
01203         CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
01204         if (pBitmapCache)
01205         {
01206             // Get rid of EVERYTHING - we are dying!
01207             pBitmapCache->RemoveAllOwnedBitmaps(mykey, FALSE, CACHEPRIORITY_PERMANENT);
01208         }
01209     }
01210 }


Member Function Documentation

BOOL NodeRenderableBounded::CanTakeAttributeType CCRuntimeClass  )  [virtual]
 

This function will return TRUE when called on NodeRenderableBounded nodes and those derived from it. Determine whether or not a bounded node can take a particular kind of attribute. This is used for various objects, e.g. bitmap objects use it to accept transparent fill geometries but not normal ones, because they are always filled with the bitmap. Base class version always returns TRUE so by default an object supports all attribute types.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/08/94
Parameters:
pAttrClass - specifies the type of attribute being enquired about. [INPUTS]
Returns:
TRUE => object supports this kind of attribute. FALSE => object does not support this kind of attribute, and so it should not be applied.

Definition at line 1620 of file noderend.cpp.

01621 {
01622     return TRUE;
01623 }

BOOL NodeRenderableBounded::CaptureCached RenderRegion pRender  )  [virtual]
 

Protected Helper function Use the CaptureManager to capture the results of rendering, cache them and associate them with this Ink node.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/06/2004
Returns:
TRUE if captured data was cached
See also:
NodeRenderableBounded::RenderCached

Definition at line 2742 of file noderend.cpp.

02743 {
02744     // If cacheing is disabled bale out now!
02745     if (!NodeRenderableBounded::bEnableCacheing)
02746         return FALSE;
02747 
02748     Capture* pCapture = pRender->GetTopCapture();
02749     if (pCapture==NULL)                                         // If nothing was captured
02750         return FALSE;                                           // Then do nothing
02751 
02752     // Only stop the capture if we started it
02753     // (means we only capture whole subtrees at the mo.)
02754     if (pCapture->GetOwner()==this)
02755     {
02756 #if defined(_WIN32)
02757         LARGE_INTEGER countStart;
02758         LARGE_INTEGER countEnd;
02759         QueryPerformanceCounter(&countStart);
02760 #endif
02761         
02762         // End this capture:
02763         // Blit capture to screen
02764         // Retain bitmap because we will release it ourselves only if we fail to cache it
02765         BOOL bCached = FALSE;
02766         LPBITMAPINFO lpInfo = NULL;
02767         LPBYTE lpBits = NULL;
02768         DocRect CaptureRect = GetBoundingRect();                // Set maximum size we allow
02769         BOOL bFullCoverage = pCapture->HasFullCoverage();
02770         pRender->StopCapture(this, TRUE, FALSE, &lpInfo, &lpBits, &CaptureRect);
02771 
02772         // If the capture gave us back a bitmap, try to cache it
02773         if (lpInfo && lpBits && CaptureRect.IsValid())
02774         {
02775             // If we can't find the cache then all is lost!
02776             CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
02777             if (pBitmapCache)
02778             {
02779                 double ScaledPixelWidth = pRender->GetScaledPixelWidth();
02780                 CBitmapCacheKey inky(this, ScaledPixelWidth); //GetScaledPixelWidthDouble?
02781 
02782                 CCachedBitmap cbmp;
02783 
02784                 cbmp.pbmpBits = lpBits;
02785                 cbmp.pbmpInfo = lpInfo;
02786                 cbmp.SetCachedRect(CaptureRect);
02787                 cbmp.nPriority = CACHEPRIORITY_TEMPBITMAP_LOW;
02788                 cbmp.bFullCoverage = bFullCoverage;
02789 
02790                 if (cbmp.IsValid())
02791                 {
02792 //TRACEUSER("Phil", _T("NRB:CaptureCached %x %s\n"), this, this->GetRuntimeClass()->m_lpszClassName);
02793                     pBitmapCache->StoreBitmap(inky, cbmp);
02794                     MayBeCached = TRUE;
02795                     bCached = TRUE;
02796                 }
02797             }
02798         }
02799 
02800         // If we failed to cache the captured bitmap then release it
02801         if (lpInfo!=NULL && lpBits!=NULL && !bCached)
02802         {
02803             FreeDIB(lpInfo, lpBits, NULL, FALSE);
02804         }
02805 
02806         INT64 countCacheing = pRender->GetStoredCount();
02807 #if defined(_WIN32)
02808         QueryPerformanceCounter(&countEnd);
02809         countCacheing += countEnd.QuadPart-countStart.QuadPart;
02810 #endif
02811         pRender->SetStoredCount(countCacheing);
02812 
02813     }
02814 
02815     return TRUE;
02816 }

BOOL NodeRenderableBounded::ContainsNonMixTransparency RenderRegion pRegion  ) 
 

Find out whether this node's subtree contains non-mix transparency. Useful for optimising cacheing because while you want things to be cached as 32BPP RGBT bitmaps most of the time, non-mix transparencies can't be captured that way and so some work ahs to be done to transform down to a 24BPP RGB bitmap - better to avoid that by calling this function.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/08/2004
Parameters:
- [INPUTS]
Returns:
TRUE - The node contains non-mix transparency attributes FALSE - It doesn't

Definition at line 4699 of file noderend.cpp.

04700 {
04701     for (Node*  pKid = FindFirstDepthFirst();
04702                 pKid != NULL;
04703                 pKid = pKid->FindNextDepthFirst(this) )
04704     {
04705         if (pKid->IsAnAttribute() && ((NodeAttribute*)pKid)->IsATranspFill())
04706         {
04707             AttrFillGeometry* pTransAttr = (AttrFillGeometry*) pKid;
04708             UINT32 ttype = pTransAttr->GetTranspType();
04709             ERROR3IF(ttype<TT_NoTranspType || ttype>TT_MAX, "Someone's trying to set an unknown transp type!");
04710 
04711 //          if (!(ttype==TT_NoTranspType || ttype==TT_Mix))
04712             if (!pRegion->TranspTypeIsRGBTCompatible(ttype))
04713                 return TRUE;
04714         }
04715     }
04716 
04717     return FALSE;
04718 }

void NodeRenderableBounded::CopyCached NodeRenderableBounded pCopyOfNode  )  [virtual]
 

Copy all cached bitmaps associated with this node to be associated with the specified new node.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/10/2004
Returns:
-
See also:
NodeRenderableInk::RenderCached, CaptureCached

Definition at line 2928 of file noderend.cpp.

02929 {
02930     CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
02931 
02932     CBitmapCacheKey inky(this, 42);
02933     CCacheKeyMap::iterator pos = pBitmapCache->GetStartPosition();
02934     CCachedBitmap abitmap = pBitmapCache->FindNextOwnedBitmap(pos, inky);
02935     pCopyOfNode->MayBeCached = FALSE;
02936     while (abitmap.IsValid())
02937     {
02938         CCachedBitmap copybitmap = abitmap.Copy();
02939         CBitmapCacheKey copyinky(inky);
02940         copyinky.SetOwner(pCopyOfNode);
02941         pBitmapCache->StoreBitmap(copyinky, copybitmap);
02942 
02943         pCopyOfNode->MayBeCached = TRUE;
02944 
02945         abitmap = pBitmapCache->FindNextOwnedBitmap(pos, inky);
02946     }
02947 }

void NodeRenderableBounded::CopyCached NodeRenderableBounded pCopyOfNode,
double  dRes,
INT32  maxOption = 0
[virtual]
 

Copy fixed res cached bitmaps associated with this node to be associated with the specified new node.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/10/2004
Returns:
-
See also:
NodeRenderableInk::RenderCached, CaptureCached

Definition at line 2891 of file noderend.cpp.

02892 {
02893     CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
02894 
02895     INT32 i = 0;
02896     for (i = 0; i<=maxOption; i++)
02897     {
02898         // Copy the cached bitmap
02899         CCachedBitmap cbmp;
02900         CBitmapCacheKey inky(this, dRes, i);
02901         CBitmapCacheKey inkycopy(pCopyOfNode, dRes, i);
02902         BOOL bFound = pBitmapCache->Lookup(inky, cbmp);
02903         if (bFound)
02904         {
02905             cbmp = cbmp.Copy();
02906             pBitmapCache->StoreBitmap(inkycopy, cbmp);
02907         }
02908     }
02909     pCopyOfNode->MayBeCached = TRUE;
02910 }

void NodeRenderableBounded::CopyNodeContents NodeRenderableBounded NodeCopy  )  [protected]
 

This method copies the node's contents to the node pointed to by NodeCopy.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/4/93
Parameters:
A copy of this node [OUTPUTS]
Returns:
Errors: An assertion failure will occur if NodeCopy is NULL Scope: protected

Definition at line 1684 of file noderend.cpp.

01685 {               
01686     ENSURE(NodeCopy != NULL,"Trying to copy a node's contents into a NULL node"); 
01687     NodeRenderable::CopyNodeContents(NodeCopy); 
01688 
01689     // Node Bounded stuff
01690     NodeCopy->BoundingRectangle     = BoundingRectangle;
01691     NodeCopy->IsBoundingRectValid   = IsBoundingRectValid;
01692 
01693     // The magnetic flag
01694     NodeCopy->Magnetic              = Magnetic;
01695     NodeCopy->Dragged               = Dragged;
01696 }  

virtual DocCoord NodeRenderableBounded::FindExtendCentre  )  [inline, virtual]
 

Reimplemented from NodeRenderable.

Reimplemented in TextStory.

Definition at line 1425 of file node.h.

01425 { return GetBoundingRect().Centre(); }

DocRect NodeRenderableBounded::GetBoundingRect BOOL  DontUseAttrs = FALSE,
BOOL  HitTest = FALSE
[virtual]
 

returns the nodes bounding rectangle. If the rectangle is valid the rectangle is simply returned, but is IsBoundingRectValid is FALSE (cos someone called InvaldateBoundingRect() on this node, or one of its children) then the bounding rect is first calculated and the flag reset, before it is returned. This is the base class version of this function and will build a bounding box out of the union of the nodes childrens bounding boxes. Your node MUST replace this function if this is not what you want it to do....

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/9/94
Parameters:
DontUseAttrs - TRUE if you want to ignore all the nodes attributes [INPUTS] FALSE by default. HitTest - TRUE if being called during HitTest
Returns:
The nodes bounding rectangle

Reimplemented in NodeGroup, NodeGuideline, NodeContourController, NodeBlendPath, NodeBrushMaker, NodeClipViewController, NodeMouldGroup, NodeMouldPath, NodeBevel, NodeBevelBegin, NodeBlender, NodeBlend, NodeBrush, NodeClipView, NodeContour, NodeLiveEffect, NodeLockedEffect, NodeMoulder, NodePath, NodeRegularShape, NodeSimpleShape, AbstractTextChar, CaretNode, EOLNode, and Spread.

Definition at line 1303 of file noderend.cpp.

01304 {
01305     // if the bounding rect of this node is not valid then fill in something
01306     if (!IsBoundingRectValid || DontUseAttrs)
01307     {
01308         // just set it to be an empty rectangle
01309         DocRect BoundRect(0,0,0,0);
01310         
01311         Node* pNode = FindFirstChild();
01312         while (pNode!=NULL)
01313         {
01314             // Add in the bounding rect of this node with all the others
01315             if (pNode->IsBounded())
01316                 BoundRect = BoundRect.Union(((NodeRenderableBounded*)pNode)->GetBoundingRect(DontUseAttrs));
01317 
01318             // And find the next node
01319             pNode = pNode->FindNext();
01320         }
01321 
01322         if (DontUseAttrs)
01323         {
01324             // We do not want to update the cached bounding rect here
01325             return BoundRect;
01326         }
01327 
01328         // Copy the unions into the nodes bounding rect param
01329         BoundingRectangle = BoundRect;
01330 
01331         // mark the bounding rect as valid
01332         IsBoundingRectValid = TRUE;
01333     }
01334 
01335     // and return the bounding rect
01336     return BoundingRectangle;
01337 }

void NodeRenderableBounded::GetDebugDetails StringBase Str  )  [virtual]
 

For obtaining debug information about the Node.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/9/93
Parameters:
Str,: String giving debug info about the node [OUTPUTS]

Reimplemented from NodeRenderable.

Reimplemented in Chapter, NodeGrid, NodeGridRect, NodeGridIso, NodeGuideline, Layer, NodeBrushMaker, NodeClipViewController, NodeBevel, NodeBlender, NodeDocument, NodeMoulder, NodeMould, NodePath, NodeRegularShape, NodeSimpleShape, VisibleTextNode, AbstractTextChar, TextChar, KernCode, CaretNode, EOLNode, TextLine, TextStory, NodeRenderablePaper, Page, and Spread.

Definition at line 1709 of file noderend.cpp.

01710 {
01711 #ifdef _DEBUG
01712     NodeRenderable::GetDebugDetails(Str);   
01713     String_256 TempStr; 
01714 
01715     // Find out about the node up to date bounding rect
01716     DocRect Bounds = GetBoundingRect();
01717     if (!Bounds.IsValid())
01718     { 
01719         TempStr = TEXT("\r\nBounding Rectangle = *INVALID*\r\n"); 
01720     }
01721     else
01722         TempStr._MakeMsg(TEXT("\r\nBounding Rectangle\r\n   Low(#1%ld, #2%ld)\r\n   High(#3%ld, #4%ld)\r\n"),    
01723                               Bounds.LowCorner().x,  
01724                               Bounds.LowCorner().y,
01725                               Bounds.HighCorner().x,  
01726                               Bounds.HighCorner().y); 
01727     (*Str)+=TempStr; 
01728 #endif
01729 }         

DocRect NodeRenderableBounded::GetEffectStackBounds BOOL *  pbFoundEffects = NULL  )  [virtual]
 

Find the bounds of any effects which might be affected by changes to this node.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/07/2005
Parameters:
- [INPUTS]
Returns:
rectangle containing bounds of topmost effect above this node

Definition at line 1499 of file noderend.cpp.

01500 {
01501     DocRect drBounds = GetBoundingRect();
01502 
01503     if (pbFoundEffects)
01504         *pbFoundEffects = FALSE;
01505 
01506     Node* pParent = FindParent();
01507     while (pParent && !pParent->IsLayer())
01508     {
01509         if (pParent->IsEffect())
01510         {
01511             drBounds = ((NodeEffect*)pParent)->GetBoundingRect();
01512             if (pbFoundEffects)
01513                 *pbFoundEffects = TRUE;
01514         }
01515 
01516         pParent = pParent->FindParent();
01517     }
01518 
01519     return drBounds;
01520 }

virtual DocRect NodeRenderableBounded::GetEorDragBoundingRect  )  [inline, virtual]
 

Reimplemented in NodeGroup, NodeClipViewController, and NodeMouldGroup.

Definition at line 1355 of file node.h.

01355 { return GetBoundingRect(TRUE, FALSE); }

DocRect NodeRenderableBounded::GetExtendTargetBounds const ExtendParams ExtParams  )  [virtual]
 

Return a DocRect which contains the bounds of this node as defined and required by the Extending mechanism.

Author:
Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
Date:
02/06/2000
Parameters:
ExtParams const ref to an ExtendParams class describing the extension. [INPUTS]
[OUTPUTS] 
Returns:
The DocRect to treat as the bounding rect of this node when extending.
We treat x- and y- directions separately, and we always return our true bounds, unless we're extending in a direction, in which case we return the bounds of our extend control points. Default behaviour for this is to use the 'bounds' of our FindExtendCentre() coord.
Returns:
Errors: See also: SliceHelper::BoundingNodeSize().

Reimplemented in NodeCompound, NodeMould, and NodePath.

Definition at line 2161 of file noderend.cpp.

02162 {
02163     DocRect     drBounds    = GetBoundingRect();
02164     DocCoord    doccCentre  = FindExtendCentre();
02165     if (ExtParams.fExtendFlags & X_EXTEND)
02166         drBounds.lo.x = drBounds.hi.x = doccCentre.x;
02167     if (ExtParams.fExtendFlags & Y_EXTEND)
02168         drBounds.lo.y = drBounds.hi.y = doccCentre.y;
02169 
02170     return drBounds;
02171 }

virtual DocRect NodeRenderableBounded::GetImagemapClickableRectangle  )  [inline, virtual]
 

Reimplemented in AbstractTextChar.

Definition at line 1357 of file node.h.

01358     {
01359         return GetBoundingRect(FALSE, TRUE);
01360     }

double NodeRenderableBounded::GetRotationAngle  )  [virtual]
 

Call this function to obtain the current angle of rotation of the node. By default this is zero. Nodes derived from NodeRenderableBounded should override this function and return the angle of rotation using their own particular method Scope: public.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/1/95
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The angle of rotation of the object. This ranges from PI to -PI. Zero is on the positive x-axis. (i.e. what atan2 returns)

Reimplemented in NodePath, NodeRegularShape, and NodeSimpleShape.

Definition at line 2088 of file noderend.cpp.

02089 {
02090     return 0.0;
02091 }

DocRect NodeRenderableBounded::GetUnionBlobBoundingRect BOOL  bIncludeEffects = TRUE  )  [virtual]
 

This simply returns the result of GetBlobBoundingRect() as the default action for the base class.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
03/02/95
Returns:
DocRect - The rectangle that is the union of all the nodes selection blobs and the node's bounding rectangle

Reimplemented from NodeRenderable.

Definition at line 1352 of file noderend.cpp.

01353 {
01354     DocRect drBounds = GetBoundingRect().Union(GetBlobBoundingRect());
01355 
01356     if (!bIncludeEffects)
01357         return drBounds;
01358 
01359     // Search up the effects stack
01360 //  NodeRenderableBounded* pEffect = this;
01361     Node* pParent = FindParent();
01362     while (pParent && !pParent->IsLayer())
01363     {
01364         if (pParent->IsEffect())
01365             drBounds = ((NodeEffect*)pParent)->GetBoundingRect().Union(((NodeEffect*)pParent)->GetBlobBoundingRect());
01366 
01367         pParent = pParent->FindParent();
01368     }
01369 
01370     return drBounds;
01371 }

virtual BOOL NodeRenderableBounded::HasCachedDirectBitmap  )  [inline, virtual]
 

Reimplemented in NodeBitmapEffect.

Definition at line 1397 of file node.h.

01397 {return FALSE;}

void NodeRenderableBounded::IncludeChildrensBoundingRects DocRect pBounds  )  [virtual]
 

The child attribute Blob bounding rects are included in the BoundingRect. Note: re-written by Ed 25/4/95 Now only includes bounds of child attrs (rather than all NodeRenderableBounded) The assumption is that no child can be selected if it's parent is, so attr blobs of child nodes cannot be visible at the same time as their parents!

Author:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/7/94
Parameters:
DocRect is updated to include Childrens Bounding Rects. [OUTPUTS]
re-written by Will 5/5/95 Now uses 'FindAppliedAttributes' so it works for select inside.

Definition at line 1749 of file noderend.cpp.

01750 {
01751     // Ok, so this function should be defined in NodeRenderableInk, but that is
01752     // one heck of a change, so we'll just make sure we warn people if they try
01753     // something silly.
01754     ERROR3IF(!this->IS_KIND_OF(NodeRenderableInk), "IncludeChildrensBoundingRect called for non-ink node");
01755     
01756 #if !defined(EXCLUDE_FROM_RALPH)
01757     // Find the blob Manager
01758     BlobManager* pBlobMgr = GetApplication()->GetBlobManager();
01759     if (pBlobMgr==NULL)
01760         return;
01761 
01762     // Since the only blobs that attributes have are Fill Blobs,
01763     // don't bother if the fill blobs are not visible
01764     BlobStyle VisibleBlobs = pBlobMgr->GetCurrentInterest(TRUE);
01765     if (VisibleBlobs.Fill)
01766     {
01767         CCAttrMap* pAttribMap = new CCAttrMap(30);
01768         if (pAttribMap == NULL)
01769             return;
01770 
01771         // Now find any attributes that are applied to this node.
01772         BOOL FoundAttrs = ((NodeRenderableInk*)this)->FindAppliedAttributes(pAttribMap, 5000, NULL, FALSE);
01773 
01774         if (FoundAttrs)
01775         {
01776             // iterating all (key, value) pairs
01777             for (CCAttrMap::iterator Pos = pAttribMap->GetStartPosition(); Pos != pAttribMap->GetEndPosition();)
01778             {
01779                 void *pVal;
01780                 CCRuntimeClass *pType;
01781                 pAttribMap->GetNextAssoc(Pos,pType,pVal);
01782 
01783                 NodeAttribute* pAttr = (NodeAttribute*)pVal;
01784                 *pBounds=pBounds->Union( pAttr->GetBlobBoundingRect() );
01785             }
01786         }
01787 
01788         delete pAttribMap;
01789     }
01790 #endif
01791 }         

BOOL NodeRenderableBounded::Init void   )  [static]
 

Declare the preferences for the magnetic options. Now also declares the layers section rather than having a new explicit init in the layers section.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/11/94
Returns:
TRUE if it worked, FALSE if not

Reimplemented from SimpleCCObject.

Reimplemented in NodeRenderableInk, Layer, NodeBitmapEffect, VisibleTextNode, AbstractTextChar, TextLine, BaseTextClass, and TextStory.

Definition at line 1885 of file noderend.cpp.

01886 {
01887 #if !defined(EXCLUDE_FROM_RALPH)
01888     // Declare the section that the magnetic options will live in
01889     BOOL Worked = Camelot.DeclareSection(TEXT("Magnetic Options"), 2);
01890 
01891     // declare the 2 prefs that there are
01892     if (Worked)
01893         Worked = Camelot.DeclarePref(TEXT("Magnetic Options"), TEXT("Point Radius"),
01894                                     &MagneticPointRadius, 0);
01895 
01896     if (Worked)
01897         Worked = Camelot.DeclarePref(TEXT("Magnetic Options"), TEXT("Line Radius"),
01898                                     &MagneticLineRadius, 0);
01899 
01900     // Declare the section that the preferences for layers will live in
01901     if (Worked)
01902         Worked = Camelot.DeclareSection(TEXT("Layers"), 2);
01903 
01904     // declare the 2 prefs that there are
01905     if (Worked)
01906         Worked = Camelot.DeclarePref(TEXT("Layers"), TEXT("ActiveLayerVisibleAndEditable"),
01907                                     &Layer::ActiveLayerVisibleAndEditable, 0, 1);
01908 
01909     if (Worked)
01910         Worked = Camelot.DeclarePref(TEXT("Layers"), TEXT("EnableLayerCacheing"),
01911                                     &Layer::EnableLayerCacheing, 0, 2);
01912 
01913     // Declare the section that the preferences for layers will live in
01914     if (Worked)
01915         Worked = Camelot.DeclareSection(TEXT("Rendering"), 4);
01916 
01917     if (Worked)
01918         Worked = Camelot.DeclarePref(TEXT("Rendering"), TEXT("Cacheing"),
01919                                     &bEnableCacheing, 0);
01920 
01921     if (Worked)
01922         Worked = Camelot.DeclarePref(TEXT("Rendering"), TEXT("ThrottleCacheing"),
01923                                     &bThrottleCacheing, 0);
01924 
01925     if (Worked)
01926         Worked = Camelot.DeclarePref(TEXT("Rendering"), TEXT("ShowCacheBlobs"),
01927                                     &bShowCacheBlobs, 0);
01928 
01929     // Return if it worked or not
01930     return Worked;
01931 #else
01932     return TRUE;
01933 #endif
01934 }

void NodeRenderableBounded::InvalidateBoundingRect BOOL  InvalidateChildBounds = FALSE  )  [virtual]
 

Marks the bounding rect of this node as invalid, as well as marking this nodes parents as invalid as well. Next time a nodes GetBoundingRect() function is called the bounding rect will be recalculated if needed.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> / Recursion moved to new function by Simon
Date:
11/9/94
Parameters:
InvalidateChildBounds - When TRUE all children of the node have their [INPUTS] bounds invalidated as well (eg. applying a line attribute to a group)

Definition at line 1450 of file noderend.cpp.

01451 {
01452     // Invalid this nodes bounding rect if we need to
01453     if (IsBoundingRectValid)
01454     {
01455         InvalidateBoundingRectHelper();
01456         
01457         // Removed by Simon (31/03/95) I Can't see a reason to update the selection here !
01458         // Inform the range that it's invalid
01459         //SelRange* Selected = GetApplication()->FindSelection();
01460         //ERROR3IF(Selected == NULL, "Where's the selection gone ?"); 
01461         //Selected->UpdateBounds();
01462 
01463         if (InvalidateChildBounds)
01464         {
01465             // Invalidate the bounds of all children of the node
01466             Node* Current = FindFirstDepthFirst();
01467             while (Current != this)
01468             {
01469                 ERROR3IF (Current == NULL, "invalid NULL Current");
01470                 if (Current->IsBounded())
01471                 {
01472                     if (((NodeRenderableBounded*)Current)->IsBoundingRectValid)
01473                     {
01474                         ((NodeRenderableBounded*)Current)->IsBoundingRectValid = FALSE;  
01475                     }
01476                 }
01477                 Current = Current->FindNextDepthFirst(this); 
01478             } 
01479         }
01480 
01481     }
01482 }

void NodeRenderableBounded::InvalidateBoundingRectHelper  )  [private]
 

Marks the bounding rect of this node as invalid, as well as marking this nodes parents as invalid as well. Next time a nodes GetBoundingRect() function is called the bounding rect will be recalculated if needed.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/9/94 Scope: private
This is the recursive helper function for NodeRenderableBounded::InvalidateBoundingRect

SeeAlso NodeRenderableBounded::InvalidateBoundingRect

Definition at line 1413 of file noderend.cpp.

01414 {
01415     // Invalid this nodes bounding rect if we need to
01416     BoundingRectangle = DocRect(0,0,0,0);
01417     if (IsBoundingRectValid)
01418     {
01419         IsBoundingRectValid = FALSE;
01420 
01421         // and invalid this nodes parents bounding rect
01422         Node* pParent = FindParent();
01423         if (pParent!=NULL)
01424         {
01425             // Check that the tree is as expected
01426             ENSURE(pParent->IS_KIND_OF(NodeRenderableBounded), "Parent of a bounded node was not bounded");
01427 
01428             // sort of recurse up the tree invalidating the bounding rects as we go
01429             if (pParent->IsBounded())
01430                 ((NodeRenderableBounded*)pParent)->InvalidateBoundingRectHelper();
01431         }
01432     }
01433 }

virtual BOOL NodeRenderableBounded::IsBounded  )  const [inline, virtual]
 

Reimplemented from Node.

Definition at line 1367 of file node.h.

01367 {return TRUE;}

BOOL NodeRenderableBounded::IsDifferent Node pOther  )  [virtual]
 

Determine if 2 nodes are considered different.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/2/97
Parameters:
pOther - The node to compare this one to [INPUTS]
Returns:
TRUE if this is considered different from pOther, FALSE if they are the same
Notes: **** IMPORTANT - May not function well enough for your needs! ****

This was written to allow the StrokeComponent class to merge stroke definitions which share identical clipart subtrees. Stroke subtrees are special in that they have had Make Shapes applied to them, and so only contain paths. Hence, I have only defined functions in Node, NodeRenderableBounded, and NodePath - most objects in the tree thus use base class functionality (are they of the same class, and do they have identical bounding boxes). This suffices for my needs, but you may need to implement this function for a lot more node types before it's of use to you.

Reimplemented from Node.

Reimplemented in NodePath.

Definition at line 2123 of file noderend.cpp.

02124 {
02125     // First, check with the base class - this checks the classes are the same type
02126     if (NodeRenderable::IsDifferent(pOther))
02127         return(TRUE);
02128 
02129     ERROR3IF(GetRuntimeClass() != pOther->GetRuntimeClass(),
02130             "Node::IsDifferent base class method seems to have been broken");
02131 
02132     // Now check if the bounds of the nodes are the same
02133     if (BoundingRectangle != ((NodeRenderableBounded *)pOther)->BoundingRectangle)
02134         return(TRUE);
02135 
02136     return(FALSE);
02137 }

BOOL NodeRenderableBounded::IsIntersectedWith DocRect pClipRect  ) 
 

Determine if this node is intersected with the rectangle supplied.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/9/94
Parameters:
pClipRect [INPUTS]
Returns:
TRUE if this node is intersected witht he doc rect

Definition at line 1572 of file noderend.cpp.

01573 {
01574     // Go find out about my bounding rectangle
01575     DocRect Bounds = GetBoundingRect();
01576 
01577     // and return if we intersect
01578     return( pClipRect->IsIntersectedWith(Bounds));
01579 }

BOOL NodeRenderableBounded::IsMagnetic  )  [virtual]
 

Returns that magnetic state of this node Scope: public.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/9/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE - the node is magnetic FALSE - the node is not magnetic

Definition at line 1994 of file noderend.cpp.

01995 {
01996     return Magnetic;
01997 }

BOOL NodeRenderableBounded::IsMagneticallyClose DocCoord pTest,
DocCoord pOriginal
[protected]
 

Tests to see if the 2 coordinates are close enough together to qualify as Magnetically close to each other. If they are, then pOriginalCoord is Modified to match pTestCoord and TRUE id returned. If not, then all the coords are left alone and FALSE is returned.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/11/94
Parameters:
pTestCoord - the coord we are testing the original against [INPUTS] pOriginalCoord - The Coord that we are trying to snap to the test coord
pOriginalCoord - If the 2 coords are close enough together (as defined by [OUTPUTS] the MagneticPointRadius) then pOriginalCoord is changed to match pTestCoord
Returns:
TRUE if it snapped the original coord to the test coord

Definition at line 1956 of file noderend.cpp.

01957 {
01958 #if !defined(EXCLUDE_FROM_RALPH)
01959     // Find out if anything is close to this coord
01960     if ((abs(pTest->x - pOriginal->x) < CSnap::GetSnapToCoordDist()) &&
01961         (abs(pTest->y - pOriginal->y) < CSnap::GetSnapToCoordDist()))
01962     {
01963         // They are close to each other
01964         // Snap the original coord to the test coord
01965         pOriginal->x = pTest->x;
01966         pOriginal->y = pTest->y;
01967 
01968         // return true to indicate what has happened
01969         return TRUE;
01970     }
01971 #endif
01972     // They were not close to each other, so say so
01973     return FALSE;
01974 }

void NodeRenderableBounded::PolyCopyNodeContents NodeRenderable pNodeCopy  )  [virtual]
 

Polymorphically copies the contents of this node to another.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/12/2003
Parameters:
- [OUTPUTS]
Returns:
Errors: An assertion failure will occur if NodeCopy is NULL Scope: protected

Reimplemented from NodeRenderable.

Reimplemented in Chapter, NodeGrid, NodeGridRect, NodeGridIso, NodeGroup, NodeGuideline, Layer, NodeContourController, NodeBlendPath, NodeBrushMaker, NodeBrushPath, NodeClipViewController, NodeMouldGroup, NodeMouldBitmap, NodeMouldPath, NodeAnimatingBitmap, NodeBevel, NodeBlender, NodeBlend, NodeBitmap, NodeBrush, NodeClipView, NodeContour, NodeDocument, NodeLiveEffect, NodeLockedEffect, NodeFeatherEffect, NodeMoulder, NodeMould, NodePath, NodeEffect, NodeRegularShape, NodeSimpleShape, AbstractTextChar, TextChar, KernCode, HorizontalTab, EOLNode, TextLine, BaseTextClass, TextStory, NodeRenderablePaper, Page, and Spread.

Definition at line 1661 of file noderend.cpp.

01662 {
01663     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
01664     ENSURE(pNodeCopy->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded)), "PolyCopyNodeContents given wrong dest node type");
01665 
01666     if (pNodeCopy->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableBounded)))
01667         CopyNodeContents((NodeRenderableBounded*)pNodeCopy);
01668 }

BOOL NodeRenderableBounded::ReleaseCached BOOL  bAndParents = TRUE,
BOOL  bAndChildren = TRUE,
BOOL  bSelf = TRUE,
BOOL  bAndDerived = TRUE
[virtual]
 

Protected Helper function Use the CaptureManager to capture the results of rendering, cache them and associate them with this Ink node.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/06/2004
Returns:
TRUE if captured data was cached
See also:
NodeRenderableInk::RenderCached, CaptureCached

Reimplemented in NodeBitmap, and NodeLiveEffect.

Definition at line 2838 of file noderend.cpp.

02839 {
02840     if (MayBeCached)
02841     {
02842         BOOL bRemoveOpaqueBitmapsOnly = IsDragged();                // If we're being dragged, only remove opaque bmps
02843         BOOL bDidRemoveSome = FALSE;
02844         CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
02845         if (pBitmapCache!=NULL && bSelf)
02846         {
02847             CBitmapCacheKey inky(this, 42);
02848             bDidRemoveSome = pBitmapCache->RemoveAllOwnedBitmaps(inky, bRemoveOpaqueBitmapsOnly);
02849         }
02850 
02851         if (bDidRemoveSome && !bRemoveOpaqueBitmapsOnly)            // If we know we removed all cached bitmaps
02852             MayBeCached = FALSE;                                    // Then we can clear our maybe flag to optimise rendering
02853     }
02854 
02855     // If we should release our children's caches as well...
02856     if (bAndChildren)
02857     {
02858         Node* pChild = FindFirstChild();
02859         while (pChild)
02860         {
02861             if (pChild->IsBounded())
02862                 ((NodeRenderableBounded*)pChild)->ReleaseCached(FALSE, TRUE, TRUE, TRUE);
02863 
02864             pChild = pChild->FindNext();
02865         }
02866     }
02867 
02868     // If I can't be cached, neither can my parent...
02869     if (bAndParents && FindParent() && FindParent()->IsBounded())
02870         ((NodeRenderableBounded*)FindParent())->ReleaseCached(TRUE, FALSE, TRUE, TRUE);
02871 
02872     return TRUE;
02873 }

BOOL NodeRenderableBounded::RenderCached RenderRegion pRender  )  [virtual]
 

Protected Helper function Allow this node to render itself using cached data if it has it and for that cached data to represent an arbitrary section of the document (usually a subtree but can be more).

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/06/2004
Returns:
TRUE if the node managed to render a cached version of itself then pNextNode contains the pointer to the node to continue rendering from FALSE if the node did not render a cached version of itself and thus normal rendering is required
For this implementation we assume that our cached info will represent just this subtree.

Also start to capture the rendered info into a cached bitmap if possible

See also:
NodeRenderableBounded::CaptureCached

Definition at line 2540 of file noderend.cpp.

02541 {
02542     // Standard implementation of RenderCached takes note of RenderRegion.BackmostChangedNode
02543     // and uses the global CBitmapCache object...
02544     //
02545     // First, try to find quick ways to do nothing...
02546     // If cacheing is disabled bale out now!
02547     if (!NodeRenderableBounded::bEnableCacheing)
02548         return FALSE;
02549 
02550 //TRACEUSER("Phil", _T("NRB::RenderCached for %x %s\n"), this, GetRuntimeClass()->m_lpszClassName);
02551     // If the rendering quality is outline - no point showing cached bitmaps...
02552     if (pRender->RRQuality.GetFillQuality() <= Quality::Solid)
02553         return FALSE;
02554 
02555     // If the rendering system is doing black and white only then we can't sensibly
02556     // produce a monochrome version of the cached bitmap...
02557     if (pRender->IsVeryMono() || pRender->IsHitDetect() || pRender->IsPrinting() || pRender->IsWrappedRender())
02558         return FALSE;
02559 
02560     CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
02561     if (pBitmapCache==NULL)
02562         return FALSE;
02563 
02564     // If this node is definitely not cached, skip the cache rendering stuff...
02565     DocRect cliprect = pRender->GetClipRect();
02566     DocRect bounds = GetBoundingRect();                                     // Assure new bounds are recalced if they were invalid
02567     BOOL bRendered = FALSE;
02568     if (MayBeCached)
02569     {
02570         // If render region tells us to, then we must remove all 24BPP cached bitmaps
02571         // (Opaque bitmaps could capture parts of the tree underneath them and they could have changed.
02572         // That's what the ReleaseCache() function is telling us.)
02573         CBitmapCacheKey inky(this, pRender->GetScaledPixelWidth());         //GetScaledPixelWidthDouble?
02574 
02575         Node* pBackmostChanged = pRender->GetBackmostChangedNode();
02576         if (pBackmostChanged)
02577         {
02578             // Only delete cached opaque bitmaps if they are above the lowest
02579             // changed node in this render (keep ones that are below because they are still valid)
02580             //
02581             // (Remember that the bounds of this object should already have been checked against
02582             // the clipping rectangle before this function is called, so we will only be chucking
02583             // out cached items that intersect the clipping rect.)
02584             //
02585             if (pBackmostChanged->IsUnder(this))
02586             {
02587                 // Then we must remove all opaque bitmaps in the cache
02588                 // associated with this node
02589 //TRACEUSER("Phil", _T("NRB:RenderCached release transp bitmaps %x %s\n"), this, this->GetRuntimeClass()->m_lpszClassName);
02590                 BOOL bRemoved = pBitmapCache->RemoveAllOwnedBitmaps(inky, TRUE);    // Only remove opaque bitmaps
02591                 if (bRemoved) MayBeCached = FALSE;                                  // assume that is some were opaque, all were (and thus all have been removed)...
02592             }
02593         }
02594 
02595         // Look for a cached bitmap at the appropriate pixel size...
02596         CCachedBitmap cbmp;
02597         BOOL bFound = pBitmapCache->Lookup(inky, cbmp);
02598         if (bFound)
02599         {
02600             // If cached bitmap covers the current clipped object rect, we can use it...
02601             DocRect clippedboundrect = cliprect.Intersection(bounds);
02602             if (cbmp.GetCachedRect().ContainsRect(clippedboundrect))
02603             {
02604 //TRACEUSER("Phil", _T("NRB::RenderCached Rendering cached bitmap for %x %s %d\n"), this, GetRuntimeClass()->m_lpszClassName, cbmp.pbmpInfo->bmiHeader.biBitCount);
02605                 bRendered = pRender->RenderBits(cbmp.pbmpInfo, cbmp.pbmpBits, &cbmp.coord0, 3);
02606             }
02607         }
02608     }
02609 
02610     if (bRendered)
02611         return TRUE;
02612 
02613     // --------------------------------------------------------------------
02614     // Now we must decide whether we can afford to cache this node...
02615     //
02616 
02617     // If this is being (solid) dragged don't waste time trying to cache it
02618 //  if (IsDragged())
02619 //      return FALSE;
02620 
02621     // Any sort of drag prevents new cacheing (to keep drags running smoothly)
02622     if (Operation::GetCurrentDragOp())
02623         return FALSE;
02624 
02625 //TRACEUSER("Phil", _T("NRB:RenderCached prep capture %x %s\n"), this, this->GetRuntimeClass()->m_lpszClassName);
02626     // Do the following optimisation only on unselected nodes...
02627     if (!IsSelected())
02628     {
02629         // This is a performance optimisation to reduce cacheing overhead...
02630         // If there are more than 2 nested captures already running, don't try another one...
02631         if (pRender->GetCaptureDepth() > 2)
02632             return FALSE;
02633 
02634         // We can use cache throttling to prevent this node being cached
02635         //
02636         // If we've run out of time to do cacheing then stop now.
02637         // if (time spent cacheing thus far is >5% of total rendering time) then don't do any more
02638 //      Node* pParent = FindParent();
02639         if (NodeRenderableBounded::bThrottleCacheing &&
02640             pRender->GetStoredCount()*((INT64)20) > pRender->GetTotalCount() //&&
02641 //          !IsSelected() &&            // Selected nodes can't be throttled
02642 //          pParent &&                  // Nodes without parents can't be trottled
02643 //          pParent->IsLayer()          // Nodes whose parents are layers can't be throttled
02644             )
02645         {
02646 //TRACEUSER("Phil", _T("NRB:RenderCached throttling prevents capture %x %s %I64d %I64d\n"), this, this->GetRuntimeClass()->m_lpszClassName, pRender->GetStoredCount()*(INT64)20, pRender->GetTotalCount());
02647             return FALSE;
02648         }
02649 //TRACEUSER("Phil", _T("NRB:RenderCached throttling allows capture %x %s %I64d %I64d\n"), this, this->GetRuntimeClass()->m_lpszClassName, pRender->GetStoredCount()*(INT64)20, pRender->GetTotalCount());
02650     }
02651 
02652 #if defined(_WIN32)
02653     // If we couldn't find or render a cached bitmap then try to cache a new one
02654     // Start timing of this cacheing overhead code
02655     LARGE_INTEGER countStart;
02656     LARGE_INTEGER countEnd;
02657     QueryPerformanceCounter(&countStart);
02658 #endif
02659     
02660     double ScaledPixelWidth = pRender->GetScaledPixelWidth();
02661 
02662     // Work out how much of the object we propose to capture
02663     // (This may change during the Capture if we have to fall back to 24BPP opaque capture)
02664     DocRect viewrect = cliprect;
02665     DocRect CaptureRect = bounds;
02666 
02667     // Only do stuff if the cliprect is at least half the size of the object
02668     if (cliprect.Width()>(bounds.Width()/2) && cliprect.Height()>(bounds.Height()/2))
02669     {
02670 
02671         View* pView = pRender->GetRenderView();
02672         Spread* pSpread = pRender->GetRenderSpread();
02673         if (pView && pSpread)
02674         {
02675             viewrect = pView->GetDocViewRect(pSpread);
02676             pSpread->DocCoordToSpreadCoord(&viewrect);
02677             if (!viewrect.IsValid() || !viewrect.ContainsRect(cliprect))
02678                 viewrect = cliprect;
02679         }
02680         CaptureRect = CaptureRect.Intersection(viewrect);               // Proposed capture area is obj x viewport
02681 
02682         if (CaptureRect.IsValid())
02683         {
02684             // If we're nearly going to capture the whole object
02685             // (Compare area of bounding rect with area of view rect so that bitmap sizes don't get out of control)
02686             XLONG areaBounds = (XLONG)bounds.Width()*(XLONG)bounds.Height();
02687             XLONG area2View = (XLONG)2*(XLONG)viewrect.Width()*(XLONG)viewrect.Height();
02688             if (areaBounds < area2View)
02689             {
02690                 // Then grab the whole thing
02691                 // (Bounding Rect is small enough for us to capture the whole object ignoring clipping rect)
02692                 CaptureRect = bounds;
02693             }
02694 
02695             // Inflate by one pixel all round to allow for anti-aliasing effects at the edges
02696             CaptureRect.Inflate((INT32)ScaledPixelWidth);
02697 
02698             UINT32 flagCoverage = 0;
02699             if (CaptureRect.ContainsRect(bounds))
02700                 flagCoverage = cfFULLCOVERAGE;
02701 
02702             // Only cache if it's worth it!
02703             if (CaptureRect.Width()>=ScaledPixelWidth*4 || CaptureRect.Height()>=ScaledPixelWidth*4)
02704             {
02705                 // It's quicker to scan ahead looking for non-mix transparency than to find it
02706                 // half way through rendering a bitmap...
02707 //TRACEUSER("Phil", _T("NRB:RenderCached start capture %x %s\n"), this, this->GetRuntimeClass()->m_lpszClassName);
02708                 CaptureFlags caFlags(flagCoverage | cfPIXWIDTHSCALE | (this->ContainsNonMixTransparency(pRender) ? cfGRABRENDERED : cfCOLLAPSETOMASTER | cfUNCLIP) );
02709                 pRender->StartCapture(this, CaptureRect, CAPTUREINFO(ctNESTABLE, caFlags), TRUE, FALSE);
02710             }
02711         }
02712     }
02713 
02714 #if defined(_WIN32)
02715     // Add up time spent doing cacheing work and store it in the render region
02716     INT64 countCacheing = pRender->GetStoredCount();
02717     QueryPerformanceCounter(&countEnd);
02718     countCacheing += countEnd.QuadPart-countStart.QuadPart;
02719     pRender->SetStoredCount(countCacheing);
02720 #endif
02721     
02722     return FALSE;
02723 }

void NodeRenderableBounded::RenderEffectAttributes RenderRegion pRegion  )  [virtual]
 

Render any effect attributes attached to this node.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/01/2005
Returns:
-
See also:
-

Definition at line 3019 of file noderend.cpp.

03020 {
03021     Node* pNode = FindLastChild(CC_RUNTIME_CLASS(NodeRenderableBounded));
03022     while (pNode)
03023     {
03024         pNode = pNode->FindNext();
03025         if (pNode && pNode->IsAnAttribute())
03026         {
03027             pNode->Render(pRegion);
03028         }
03029     }
03030 }

SubtreeRenderState NodeRenderableBounded::RenderSubtree RenderRegion pRender,
Node **  ppNextNode = NULL,
BOOL  bClip = TRUE
[virtual]
 

Virtual function - this function will indicate to the caller whether or not we want to render the given node, according to the information passed in.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
07/02/94
Parameters:
pRender - A pointer to the current render region (NULL if none) [INPUTS]
Returns:
TRUE => This node should be rendered, FALSE => This node does not need to be rendered.
See also:
Node::NeedsToRender

Reimplemented from NodeRenderable.

Reimplemented in NodeGrid, NodeGroup, NodeGuideline, Layer, NodeContourController, NodeClipViewController, NodeMouldGroup, NodeBevelBegin, NodeBrush, NodeClipView, NodeLiveEffect, NodeLockedEffect, NodeEffect, NodeRenderablePaper, and Spread.

Definition at line 1540 of file noderend.cpp.

01541 {
01542     if (pRender == NULL)                            // If no render region supplied, assume we need to be rendered
01543         return SUBTREE_ROOTANDCHILDREN;
01544 
01545     // Go find out about my bounding rectangle
01546     DocRect Bounds = GetBoundingRect();
01547     DocRect ClipRect = pRender->GetClipRect();
01548 
01549     if (bClip && !ClipRect.IsIntersectedWith(Bounds))   // If not within the clipping rect then
01550         return SUBTREE_NORENDER;                    // Don't render us or our children
01551 
01552 //  if (RenderCached(pRender, ppNextNode))          // If we can find a cached bitmap for this node and render it
01553 //      return SUBTREE_NORENDER;                    // Then tell the renderer to move on without doing any more...
01554 
01555     return SUBTREE_ROOTANDCHILDREN;                 // Else we must render ourselves and our children
01556 }

void NodeRenderableBounded::SetMagneticState BOOL  state  )  [virtual]
 

Allows you to set the magnetic state of this node Scope: public.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/9/94
Parameters:
State - TRUE to become magnetic, FALSE otherwise [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 2014 of file noderend.cpp.

02015 {
02016     Magnetic = state;
02017 }

Node * NodeRenderableBounded::SimpleCopy void   )  [protected, virtual]
 

This method returns a shallow copy of the node with all Node pointers NULL. The function is virtual, and must be defined for all derived classes.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/4/93
Returns:
A copy of the node, or NULL if memory has run out

Errors: If memory runs out when trying to copy, then ERROR is called with an out of memory error and the function returns NULL.

Reimplemented from NodeRenderable.

Reimplemented in Chapter, NodeGrid, NodeGridRect, NodeGridIso, NodeGroup, NodeGuideline, NodeRenderableInk, Layer, NodeContourController, NodeBlendPath, NodeBrushMaker, NodeBrushPath, NodeClipViewController, NodeMouldGroup, NodeMouldBitmap, NodeMouldPath, NodeAnimatingBitmap, NodeBevel, NodeBevelBegin, NodeBlender, NodeBlend, NodeBitmap, NodeBrush, NodeClipView, NodeContour, NodeDocument, NodeEllipse, NodeLiveEffect, NodeLockedEffect, NodeFeatherEffect, NodeMoulder, NodeMould, NodePath, NodeEffect, NodeRect, NodeRegularShape, NodeSimpleShape, VisibleTextNode, AbstractTextChar, TextChar, KernCode, HorizontalTab, CaretNode, EOLNode, TextLine, BaseTextClass, TextStory, NodeRenderablePaper, Page, and Spread.

Definition at line 1638 of file noderend.cpp.

01639 {
01640     NodeRenderableBounded* NodeCopy; 
01641     NodeCopy = new NodeRenderableBounded();
01642     ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); 
01643     CopyNodeContents(NodeCopy);   
01644     return (NodeCopy);
01645 }   

BOOL NodeRenderableBounded::Snap DocRect pDocRect,
const DocCoord PrevCoord,
const DocCoord CurCoord
[virtual]
 

ALWAYS RETURNS FALSE! This is just a virtual base function intended to be overridden. Scope: public.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/9/94
Parameters:
pDocCoord - the rectangle to snap [INPUTS] StartDrag - Start coord of drag EndDrag - End coord of drag
[OUTPUTS] 
Returns:
TRUE - the DocRect been snapped to the grid. FALSE - the DocRect has not been processed.

Reimplemented in NodeGrid, NodeGridRect, NodeGridIso, NodeGuideline, NodeBlender, NodePath, NodeRegularShape, NodeSimpleShape, and Page.

Definition at line 1835 of file noderend.cpp.

01836 {
01837     return (FALSE);
01838 }

BOOL NodeRenderableBounded::Snap DocCoord pDocCoord  )  [virtual]
 

ALWAYS RETURNS FALSE! This is just a virtual base function intended to be overridden.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/9/94
Parameters:
pDocCoord = a coord in Spread coords [INPUTS]
[OUTPUTS] 
Returns:
TRUE - the DocCoord has been snapped to the path. FALSE - the DocCoord has not been processed.

Errors: Scope: public

Reimplemented in NodeGrid, NodeGridRect, NodeGridIso, NodeGuideline, NodeBlender, NodePath, NodeRegularShape, NodeSimpleShape, TextChar, and Page.

Definition at line 1811 of file noderend.cpp.

01812 {
01813     return (FALSE);
01814 }

BOOL NodeRenderableBounded::SnapToCoords DocCoord pDocCoord  )  [virtual]
 

This is a form of Magnetic snapping. It Snaps the Coordinates to the Significant points around a shape. eg. It would snap to the EndPoints along a path, the centre and corners of a rectangle etc. This snapping is more powerful than the normal magnetic snapping, so that these significant points can be snapped to more easily. This is the base class version of the function and does no snapping at all. It always returns FALSE. If you want your node to make use of this sort of snapping, override this function and use the MagneticPointRadius to decide if the DocCoord is close enough to be snapped.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/11/94
Parameters:
pDocCoord - The DocCoord that needs snapping [INPUTS]
If the function returns TRUE then pDocCoord will have been modified to [OUTPUTS] snap to a significant point on the node.
Returns:
TRUE if the Coord was snapped. FALSE if the coord was not effected by this node
See also:
MagneticPointRadius; MagneticLineRadius; NodePath::SnapToCoords

Reimplemented in NodePath, NodeRect, NodeRegularShape, and NodeSimpleShape.

Definition at line 1866 of file noderend.cpp.

01867 {
01868     return FALSE;
01869 }

void NodeRenderableBounded::Transform TransformBase Trans  )  [virtual]
 

Base class transform function.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/9/94
Parameters:
Trans - The transform [INPUTS]

Reimplemented from NodeRenderable.

Reimplemented in NodeGroup, NodeGuideline, NodeContourController, NodeBrushMaker, NodeBrushPath, NodeClipViewController, NodeMouldGroup, NodeBevel, NodeBlender, NodeBrush, NodeClipView, NodeContour, NodeLiveEffect, NodeLockedEffect, NodeMoulder, NodeMould, NodePath, NodeRegularShape, NodeSimpleShape, and TextStory.

Definition at line 1224 of file noderend.cpp.

01225 {
01226     // Just transform the children and invalidate the nodes bounding rect
01227     InvalidateBoundingRect();
01228     TransformChildren(Trans);
01229 }

void NodeRenderableBounded::TransformCached TransformBase Trans,
double  dTestPixelWidth
[virtual]
 

Transform all the cached bitmaps associated with this node.

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/10/2004
Parameters:
Trans - Transformation [INPUTS] dPixelWidth - PixelWidth to be tested specifically to control Trans.bHaveTransformedCached
Returns:
-
See also:
NodeRenderableInk::RenderCached, CaptureCached

Definition at line 2966 of file noderend.cpp.

02967 {
02968     // If cacheing is disabled bale out now!
02969     if (!NodeRenderableBounded::bEnableCacheing)
02970     {
02971         MayBeCached = FALSE;
02972         Trans.bHaveTransformedCached = FALSE;
02973         Trans.bTransformYourChildren = TRUE;
02974         return;
02975     }
02976 
02977     CBitmapCache* pBitmapCache = Camelot.GetBitmapCache();
02978 
02979     CBitmapCacheKey inky(this, 42);
02980     CCacheKeyMap::iterator pos = pBitmapCache->GetStartPosition();
02981     CCachedBitmap abitmap = pBitmapCache->FindNextOwnedBitmap(pos, inky);
02982     MayBeCached = abitmap.IsValid();                        // Update MayBeCached here because we can
02983     BOOL bTransformedTested = FALSE;
02984     while (abitmap.IsValid())
02985     {
02986         abitmap.Transform(Trans);
02987         pBitmapCache->StoreBitmap(inky, abitmap);
02988 
02989         if (inky.GetPixelWidth() == dTestPixelWidth && abitmap.IsTransparent())
02990             bTransformedTested = TRUE;
02991 
02992         abitmap = pBitmapCache->FindNextOwnedBitmap(pos, inky);
02993     }
02994 
02995     // We can only continue to transform cached things if all our bitmaps are transparent (32BPP)
02996     // And if we actually had some cached data to transform
02997     if (!bTransformedTested)
02998     {
02999         Trans.bHaveTransformedCached = FALSE;
03000         Trans.bTransformYourChildren = TRUE;
03001     }
03002 }

void NodeRenderableBounded::TransformChildren TransformBase Trans  )  [virtual]
 

Transforms the Child nodes of this node. This allows fills etc to move with the objects.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
11/9/94
Parameters:
Trans - The transform that should be applied to all the children [INPUTS]

Reimplemented from NodeRenderable.

Definition at line 1245 of file noderend.cpp.

01246 {
01247     // We have to go through all the child nodes of this node and Transform
01248     // all the NodeRenderable objects
01249     Node* pCurrent = this -> FindFirstChild();
01250 
01251     while (pCurrent != NULL)
01252     {
01253         // Make sure it is a renderable ink object (not a hidden node)
01254         if (pCurrent->IS_KIND_OF(NodeRenderable))
01255         {
01256             // Transform the child node
01257             ((NodeRenderable*)pCurrent)->Transform( Trans );
01258 
01259             // If this node has a bounding box then invalidate it
01260             if (pCurrent->IsBounded())
01261             {
01262                 ((NodeRenderableBounded*)pCurrent)->InvalidateBoundingRect();
01263             }
01264             
01265             // Show the hourglass
01266             if (ShowHourglass())
01267             {
01268                 ContinueSlowJob(); 
01269             }
01270         }
01271 
01272         // Find the next object in the group
01273         pCurrent = pCurrent -> FindNext();
01274     }
01275 }

void NodeRenderableBounded::ValidateBoundingRect  ) 
 

Marks this nodes bounding rect as valid again. You should not generally speaking be using this function. It was created so that new nodes could be sure of invalidating their parents bounding rects. DoInsertNewNode() is the only real case in which it can be used without express written permission from the UN.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
13/9/94

Definition at line 1388 of file noderend.cpp.

01389 {
01390     IsBoundingRectValid = TRUE;
01391 }


Member Data Documentation

BOOL NodeRenderableBounded::bEnableCacheing = TRUE [static]
 

Enable or disable bitmap cacheing of parts of the tree during GRenderRegion rendering.

Preference: EnableCacheing Section: Rendering Range: 0 or 1

See also:
-

Definition at line 1448 of file node.h.

DocRect NodeRenderableBounded::BoundingRectangle [protected]
 

Definition at line 1435 of file node.h.

BOOL NodeRenderableBounded::bShowCacheBlobs = FALSE [static]
 

TRUE - Show special markers when cached groups are selected.

Preference: ShowCacheBlobs Section: Rendering Range: 0 or 1

See also:
-

Definition at line 1450 of file node.h.

BOOL NodeRenderableBounded::bThrottleCacheing = TRUE [static]
 

TRUE - Throttle cacheing to be 5% of total rendering time or less.

Preference: ThrottleCacheing Section: Rendering Range: 0 or 1

See also:
-

Definition at line 1449 of file node.h.

BOOL NodeRenderableBounded::IsBoundingRectValid [protected]
 

Definition at line 1432 of file node.h.

BOOL NodeRenderableBounded::Magnetic [protected]
 

Definition at line 1438 of file node.h.

INT32 NodeRenderableBounded::MagneticLineRadius = 750*4 [static]
 

This is the radius around a path (such as the edges of a rectangle, or the whole of a path) that will allow other points to be magnetically attracted to it. This is measured in millipoints.

Preference: Line Radius Section: Magnetic Options Range: 0 - lots

See also:
Point Radius

Definition at line 1446 of file node.h.

INT32 NodeRenderableBounded::MagneticPointRadius = 750*6 [static]
 

This is the radius around a control point (such as the corner of a rectangle, or the end point in the middle of a path) that will allow other points to be magnetically attracted to it. This is measured in millipoints.

Preference: Point Radius Section: Magnetic Options Range: 0 - lots

See also:
Line Radius

Definition at line 1445 of file node.h.

BOOL NodeRenderableBounded::MayBeCached [protected]
 

Definition at line 1440 of file node.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:57:07 2007 for Camelot by  doxygen 1.4.4