AttrFeather Class Reference

#include <fthrattr.h>

Inheritance diagram for AttrFeather:

NodeAttribute NodeRenderable Node CCObject SimpleCCObject List of all members.

Public Member Functions

 AttrFeather ()
 ~AttrFeather ()
 AttrFeather (Node *ContextNode, AttachNodeDirection Direction, BOOL Locked=FALSE, BOOL Mangled=FALSE, BOOL Marked=FALSE, BOOL Selected=FALSE)
virtual void Render (RenderRegion *pRender)
 Render this feather attribute. We do one or two checks for validity of this attr, and then render its attribute-value into the RR.
virtual AttributeValueGetAttributeValue ()
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.
virtual UINT32 GetAttrNameID ()
 Returns back a string resource ID describing the attribute, this base class function returns the resource _R(IDS_ATTRIBUTE).
virtual AttrIndex GetAttributeIndex ()
virtual UINT32 GetNodeSize ()
virtual INT32 operator== (const NodeAttribute &NodeAttrib)
 This function is slightly weird. Unlike most definitions of operator== it's virtual.
virtual BOOL NeedsTransparency () const
 Can be overriden in derived classes to return TRUE, indicating that the user may be prompted concerning transparency mode when such a node is inserted in the tree.
virtual BOOL IsAFeatherAttr () const
BOOL DoFeather (Node *pNode, INT32 size=((MILLIPOINT)(2 *PX_MP_VAL)), UnitType type=MILLIPOINTS)
BOOL DoSetProfile (CProfileBiasGain bg)
virtual SubtreeRenderState RenderSubtree (RenderRegion *pRender, Node **ppNextNode=NULL, BOOL bClip=TRUE)
 Feathering is not supported in certain circumstances listed below Rather than hacking other code to prevent these situations arising I am using this method to prevent feathers causing damage to other nodes.
virtual BOOL CanBeMultiplyApplied ()
virtual BOOL ShouldBeOptimized ()
 Feathers are layered attributes. Feathering individual members in a group will look visibly different to feathering the entire group (if any of the children overlap) Hence once a feather attribute has been inserted in to the tree it must not be moved around by the optimisation code. However, we don't want zero size feather attributes to be stuck into the tree ever. This function determines when an attribute can be optimised so determined whether we can get rid of rdundant attributes. Hence we allow optimisation to occur in the case where we have a zero width feather.
virtual void Transform (TransformBase &Trans)
 Scales the size of the feather as the feathered object is transformed.
virtual BOOL Blend (BlendAttrParam *pBlendParam)
 Blend us.
virtual BOOL IsLinkedToNodeGeometry ()
virtual BOOL IsLinkedToThisNode (Node *pNode)
virtual BOOL PostDynCreateInit (CCAttrMap *pMap, Path *InkPath, CCRuntimeClass *pCreatorClass)
 Support dynamic creation of feather attibutes by other complex nodes (just Blends and Contours so far).
virtual BOOL PostDynCreateInit (CCAttrMap *pMap, Node *pNode, CCRuntimeClass *pCreatorClass)
virtual void PostDynCreateDeInit ()
 Free memory allocated by PostDynCreateInit(..) functions.
virtual BOOL LinkedNodeGeometryHasChanged (UndoableOperation *pOp)
 Inform this attribute that the geometry of its linked node may be changing.
virtual void NewlyCreatedDefaultAttr (NodeDocument *pNode)
virtual BOOL LinkToGeometry (Node *pContext)
virtual BOOL ContainsAttributeValue (AttributeValue *pVal)
virtual BOOL IsAnOffscreenAttribute ()
virtual void PolyCopyNodeContents (NodeRenderable *pNodeCopy)
 Polymorphically copies the contents of this node to another.
virtual BOOL WritePreChildrenWeb (BaseCamelotFilter *pFilter)
 Writes out a record that represents the node.
virtual BOOL WritePreChildrenNative (BaseCamelotFilter *pFilter)

Public Attributes

FeatherAttrValue Value

Private Member Functions

void CopyNodeContents (NodeAttribute *pCopy)
 This method copies the node's contents to the node pointed to by NodeCopy.

Detailed Description

Definition at line 309 of file fthrattr.h.


Constructor & Destructor Documentation

AttrFeather::AttrFeather  )  [inline]
 

Definition at line 314 of file fthrattr.h.

00314 {}

AttrFeather::~AttrFeather  )  [inline]
 

Definition at line 315 of file fthrattr.h.

00315 {}

AttrFeather::AttrFeather Node ContextNode,
AttachNodeDirection  Direction,
BOOL  Locked = FALSE,
BOOL  Mangled = FALSE,
BOOL  Marked = FALSE,
BOOL  Selected = FALSE
[inline]
 

Definition at line 316 of file fthrattr.h.

00321                                       : 
00322         NodeAttribute(ContextNode, Direction, Locked, Mangled, Marked, Selected) {}


Member Function Documentation

BOOL AttrFeather::Blend BlendAttrParam pBlendParam  )  [virtual]
 

Blend us.

Author:
Ilan_Copelyn (Xara Group Ltd) <camelotdev@xara.com>
Date:
Mid-2000
Parameters:
pBlendParam contains the blending info. [INPUTS]
Returns:
TRUE if success, FALSE otherwise.
Notes: Always returns FALSE if blending from default to default. NB in this case will never add an attr of this type to the blended attr map hence PostDynCreateInit will not be called ('cause it doesn't get dyn created!)

Returns:
Errors: ERROR3 if NULL input param; ENSURE if pBlendParam has no blend-attr.

Reimplemented from NodeAttribute.

Definition at line 2023 of file fthrattr.cpp.

02024 {
02025     // Check entry param isn't NULL
02026     ERROR3IF(pBlendParam == NULL, "NULL entry param");
02027     if (pBlendParam == NULL)
02028         return FALSE;
02029 
02030     BOOL Success = FALSE;
02031 
02032     // We have a valid feather to blend, so do it (in the convoluted style copied from other attrs...)
02033     // Get the Value member to blend to the Value member of the other NodeAttribute.
02034     // If it succeeds, ask the blended Value to make a NodeAttribute out of itself.
02035     if (Value.Blend(pBlendParam))
02036     {
02037         // Get the blended attr val. After this call, the ptr is our reponsibility
02038         // so we have to delete it if it's no longer needed
02039         AttributeValue* pBlendedAttrVal = pBlendParam->GetBlendedAttrVal();
02040 
02041         if (pBlendedAttrVal != NULL)
02042         {
02043             // We have a blended attr val, so ask it to make a NodeAttribute out of itself
02044             // and set the pBlendParam's blended NodeAttribute ptr to it
02045             NodeAttribute* pBlendedAttr = pBlendedAttrVal->MakeNode();
02046             pBlendParam->SetBlendedAttr(pBlendedAttr);
02047 
02048             if (pBlendedAttr != NULL)
02049             {
02050                 // We were able to make a blended NodeAttribute
02051                 // so delete the blended attr val, and return TRUE
02052                 delete pBlendedAttrVal;
02053                 Success = TRUE;
02054             }
02055             else
02056             {
02057                 // Couldn't make a blended NodeAttribute, so give the blended attr val back
02058                 // and return FALSE
02059                 pBlendParam->SetBlendedAttrVal(pBlendedAttrVal);
02060                 Success = FALSE;
02061             }
02062         }
02063         else
02064         {
02065             ENSURE(FALSE,"Couldn't get blended attr val from BlendAttrParam.");
02066             Success = FALSE;
02067         }
02068     }
02069     
02070     return Success;
02071 }

virtual BOOL AttrFeather::CanBeMultiplyApplied  )  [inline, virtual]
 

Reimplemented from NodeAttribute.

Definition at line 351 of file fthrattr.h.

00351 { return TRUE; }

BOOL AttrFeather::ContainsAttributeValue AttributeValue pVal  )  [virtual]
 

Reimplemented from NodeAttribute.

Definition at line 2204 of file fthrattr.cpp.

02205 {
02206     if(!pVal->IS_KIND_OF(FeatherAttrValue))
02207     {
02208         ENSURE(FALSE,"Strange attr value comparison test requested");
02209         return FALSE;
02210     }
02211 
02212     return (pVal == &Value);
02213 }

void AttrFeather::CopyNodeContents NodeAttribute pCopy  )  [private, virtual]
 

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:
[INPUTS] 
A copy of this node [OUTPUTS]
Returns:
-

Errors: An assertion failure will occur if NodeCopy is NULL

Scope: protected

Reimplemented from NodeAttribute.

Definition at line 1616 of file fthrattr.cpp.

01617 {
01618     NodeAttribute::CopyNodeContents(pCopy);
01619     ((AttrFeather*)pCopy)->Value.SimpleCopy( &Value  );
01620 }

BOOL AttrFeather::DoFeather Node pNode,
INT32  size = ((MILLIPOINT)(2 *PX_MP_VAL)),
UnitType  type = MILLIPOINTS
 

Definition at line 1717 of file fthrattr.cpp.

01718 {
01719     return Value.SetupFeather(pNode, size, type);
01720 }

BOOL AttrFeather::DoSetProfile CProfileBiasGain  bg  ) 
 

Definition at line 1729 of file fthrattr.cpp.

01730 {
01731     return Value.ChangeFeatherProfile(bg);
01732 }

virtual AttrIndex AttrFeather::GetAttributeIndex  )  [inline, virtual]
 

Reimplemented from NodeAttribute.

Definition at line 334 of file fthrattr.h.

00334 { return ATTR_FEATHER; }

virtual AttributeValue* AttrFeather::GetAttributeValue  )  [inline, virtual]
 

Reimplemented from NodeAttribute.

Definition at line 331 of file fthrattr.h.

00331 { return &Value; }

UINT32 AttrFeather::GetAttrNameID void   )  [virtual]
 

Returns back a string resource ID describing the attribute, this base class function returns the resource _R(IDS_ATTRIBUTE).

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/2/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
Attribute description ID

Errors: -

See also:
-

Reimplemented from NodeAttribute.

Definition at line 1681 of file fthrattr.cpp.

01682 {
01683     return (_R(IDS_FEATHER_ATTR_ID)); 
01684 }                          

UINT32 AttrFeather::GetNodeSize  )  [virtual]
 

Definition at line 1693 of file fthrattr.cpp.

01694 {
01695     return sizeof(AttrFeather);
01696 }

BOOL AttrFeather::IsAFeatherAttr  )  const [virtual]
 

Reimplemented from Node.

Definition at line 1705 of file fthrattr.cpp.

01706 {
01707     return TRUE;
01708 }

virtual BOOL AttrFeather::IsAnOffscreenAttribute  )  [inline, virtual]
 

Reimplemented from NodeAttribute.

Definition at line 373 of file fthrattr.h.

00373 { return TRUE; }

virtual BOOL AttrFeather::IsLinkedToNodeGeometry  )  [inline, virtual]
 

Reimplemented from NodeAttribute.

Definition at line 357 of file fthrattr.h.

00357 { return TRUE; }

BOOL AttrFeather::IsLinkedToThisNode Node pNode  )  [virtual]
 

Author:
Ilan_Copelyn (Xara Group Ltd) <camelotdev@xara.com>
Date:
Mid-2000
Parameters:
pNode ptr to the node to check for linkage. [INPUTS]
Returns:
TRUE if we're linked to pNode, FALSE otherwise.
See Also: LinkToGeometry().

Reimplemented from NodeAttribute.

Definition at line 1956 of file fthrattr.cpp.

01957 {
01958     return (Value.GetLinkedNode() == pNode);
01959 }

BOOL AttrFeather::LinkedNodeGeometryHasChanged UndoableOperation pOp  )  [virtual]
 

Inform this attribute that the geometry of its linked node may be changing.

Author:
Ilan_Copelyn (Xara Group Ltd) <camelotdev@xara.com>; Karim MacDonald
Date:
27/4/00; 01/03/2001
Parameters:
pOp the operation causing our linked node's geometry to change. [INPUTS]
Our cache of our outer-contour path may be cleared. [OUTPUTS]
Returns:
TRUE if successful, FALSE otherwise.

Errors: ERROR2 if pOp is NULL - should *never* happen.

See also: Node::AllowOp() + overrides - main place from which this fn is called.

Reimplemented from NodeAttribute.

Definition at line 2112 of file fthrattr.cpp.

02113 {
02114 // DEBUG:
02115 //  static UINT32 ctr = 0;
02116 //  TRACEUSER( "Karim", _T("%d. LinkedNodeGeometryHasChanged() for 0x%x.\n"), ++ctr, &Value);
02117 
02118     ERROR2IF(pOp == NULL, FALSE,
02119             "AttrFeather::LinkedNodeGeometryHasChanged; Should never call with NULL pOp!");
02120 
02121     // Karim 28/02/2000
02122     // If we're undergoing translation, rotation or reflection, then our transform
02123     // method will automatically update our outer-contour.
02124     // In all other cases, we should clear out our outer-contour,
02125     // so it is refreshed at the next render.
02126     //
02127     // The only way to detect whether we're being transformed as above, is to test on the Op.
02128 
02129     if (pOp->IS_KIND_OF(TransOperation) 
02130         && !pOp->IsKindOf( CC_RUNTIME_CLASS(OpPathNudge) )
02131         )
02132     {
02133         // arbitrarily chosen error threshold.
02134         static const double epsilon = 0.000016;
02135         Matrix Mat = ((TransOperation*)pOp)->GetCurrentMatrix();
02136         if (Mat.IsTranslation() ||
02137             Mat.IsReflection() ||
02138             Mat.IsRotation(epsilon))
02139         {
02140             // can only know for sure that we were transformed,
02141             // if our linked node, or one of its parents, is the op's target.
02142             Node* pLinkedNode   = Value.GetLinkedNode();
02143 //          Node* pTransNode    = ((TransOperation*)pOp)->GetNode();
02144 //          if( pLinkedNode == pTransNode ||
02145 //              (pTransNode != NULL && pTransNode->IsNodeInSubtree(pLinkedNode)) )
02146 //              return TRUE;
02147             Range* pRange = ((TransOperation*)pOp)->GetTransformRange();
02148             if (pRange && pRange->Contains(pLinkedNode, TRUE))
02149                 return TRUE;
02150         }
02151     }
02152 
02153     return Value.RegenerateOuterContourOnNextRedraw(pOp);
02154 }

BOOL AttrFeather::LinkToGeometry Node pContext  )  [virtual]
 

Reimplemented from NodeAttribute.

Definition at line 2184 of file fthrattr.cpp.

02185 {
02186     Value.SetLinkedNode((NodeRenderableBounded*) pContext);
02187     return TRUE;
02188 }

virtual BOOL AttrFeather::NeedsTransparency  )  const [inline, virtual]
 

Can be overriden in derived classes to return TRUE, indicating that the user may be prompted concerning transparency mode when such a node is inserted in the tree.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
23/12/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if this Node requires transparency mode to render properly. By default this returns FALSE.

Errors: -

See also:
Node::AttachNode

Reimplemented from Node.

Definition at line 340 of file fthrattr.h.

00340 { return TRUE; }

void AttrFeather::NewlyCreatedDefaultAttr NodeDocument pNode  )  [virtual]
 

Reimplemented from NodeAttribute.

Definition at line 2171 of file fthrattr.cpp.

02172 {
02173     Value.SetLinkedNode((NodeRenderableBounded*)pNode);
02174     Value.SetDefault();
02175 }

INT32 AttrFeather::operator== const NodeAttribute NodeAttrib  )  [virtual]
 

This function is slightly weird. Unlike most definitions of operator== it's virtual.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/2/94
Parameters:
Atrib,: The attribute to compare [INPUTS]
- [OUTPUTS]
Returns:
-
To see why it's required, consider the following

NodeAttribute* A,B;

A = X; B = Y;

where X and Y are pointers to instances of derived classes of NodeAttribute.

if X->GetRuntimeClass() == Y->GetRuntimeClass() then we should be able to compare X and Y. But if we had defined a normal operator== fn then we find we cannot do this, because there is no way of casting to a type which is unknown at compile time.

The implementation of operator== in all derived classes of NodeAttribute should look something like this.

INT32 DerivedClass::operator==(const NodeAttribute& Attrib) { DerivedClass* Attr = (DerivedClass*)

Compare member vars with Attr }

Before calling this function you must be sure that the attributes have the same runtime class.

The function needs to be defined in all derived classes of NodeAttribute

Returns:
Errors: If this function is called on an instance of a derived class of NodeAttribute, and the function has not been defined for the derived class, then an ENSURE failure will result.
See also:
-

Reimplemented from NodeAttribute.

Definition at line 1666 of file fthrattr.cpp.

01667 {
01668     ERROR3IF(!NodeAttrib.IsAFeatherAttr(), "AttrFeather::operator==; Compared with a non-feather attr.");
01669     AttrFeather *PotentialAttrToOptimize = (AttrFeather*) &NodeAttrib;
01670 
01671     return (Value.GetFeatherSize() == PotentialAttrToOptimize->Value.GetFeatherSize());
01672 }

void AttrFeather::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.

Definition at line 1634 of file fthrattr.cpp.

01635 {
01636     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
01637     ENSURE(IS_A(pNodeCopy, AttrFeather), "PolyCopyNodeContents given wrong dest node type");
01638 
01639     if (IS_A(pNodeCopy, AttrFeather))
01640         CopyNodeContents((AttrFeather*)pNodeCopy);
01641 }

void AttrFeather::PostDynCreateDeInit  )  [virtual]
 

Free memory allocated by PostDynCreateInit(..) functions.

Author:
Ilan_Copelyn (Xara Group Ltd) <camelotdev@xara.com>
Date:
Mid-2000
Returns:
Errors: No memory needs to be allocated, so cannot fail.

Reimplemented from NodeAttribute.

Definition at line 1904 of file fthrattr.cpp.

01905 {
01906     if (Value.GetFeatherSize() == 0)
01907     {
01908         ERROR3("Failure to PostDynCreateInit should have removed this attr from the attrmap");
01909         return;     // nothing to de-alloc
01910     }
01911 
01912 
01913     // Karim 17/08/2000
01914     // This call is for completeness - probably isn't 100% necessary, but
01915     // better safe than sorry. See PostDynCreateInit() above for more info.
01916     Value.UnsetAlwaysUseTransparency();
01917 
01918     // NB this must only be called if you have called PostDynCreateInit(..)
01919 
01920     // dealloc the memory that we allocated in order to perform dynamic feathering
01921     // check parent node
01922     Node* pParent = FindParent();
01923     ENSURE(pParent->FindParent()==NULL && pParent->FindPrevious()==NULL && pParent->FindNext()==NULL,"Parent not created dynamically");
01924 
01925     // delete line attrs which we added
01926     // *** Change here if copy attrs from blendmap inside MakeLineAttributeCompleteForContouring
01927 /*  Node* pPrev = FindPrevious();
01928     if(pPrev)
01929     {
01930         ENSURE(pPrev->FindParent()==pParent,"Deleting dynamic child attrs which we didn't alloc.");
01931         pPrev->SetNextDangerous(NULL);
01932         pParent->CascadeDelete();
01933     }
01934 */  
01935     pParent->SetChildDangerous(NULL);
01936     delete pParent;
01937     return;
01938 }

BOOL AttrFeather::PostDynCreateInit CCAttrMap pMap,
Node pNode,
CCRuntimeClass pCreatorClass
[virtual]
 

Reimplemented from NodeAttribute.

Definition at line 2084 of file fthrattr.cpp.

02087 {
02088     return TRUE;
02089 }

BOOL AttrFeather::PostDynCreateInit CCAttrMap pBlendMap,
Path pInkPath,
CCRuntimeClass CreatorClass
[virtual]
 

Support dynamic creation of feather attibutes by other complex nodes (just Blends and Contours so far).

Dynamic Attribute creation

Dynamic attrs are created by CCAttrMap::MakeAppliedAttrMap which calls NodeRenderableInk::FindAppliedAttributes

However the problem is that some attributes require additional info inorder to apply themselves to a given path or node. These attributes are specific to the node that they are attached to, so need an additonal step to set themselves up after being dynamically created.

Feather attributes need their internal node pointer to be setup. This pointer is required in order to work out the dimensions of the offscreen bitmap, to place this bitmap onscreen once it has been created, and to get the inkpath so that the convolved transparency mask can be created

Reimplemented from NodeAttribute.

Definition at line 1843 of file fthrattr.cpp.

01844 {
01845     // all defaults will be out by this stage
01846     // blending default to default will return false - so no feather should be in blend attr map
01847     // blending from default to non-def will dyn create a new feather and blend it's state members
01848     //      its m_bDefault will be FALSE as it's set in the constructor
01849     ENSURE(!Value.IsDefaultFlagSet(),"How did this attribute get copied from the default attr?"); 
01850 
01851     if (Value.GetFeatherSize() == 0)
01852         return FALSE;           // Won't render and doesn't alloc mem
01853 
01854     // Karim 17/08/2000
01855     // Feather attrs usually decide for themselves whether to use a transparency-capable
01856     // bitmap when rendering. However, within contours and blends, we must force them to,
01857     // as they are now detached from the tree, and therefore cannot examine the surroundings
01858     // to make a transparency decision.
01859     Value.SetAlwaysUseTransparency();
01860 
01861     // fix internal node pointer so that we can setup offscreen bitmap
01862     // and create outer contour for generating feather mask
01863 
01864     // if we fail (eg out of mem) then put this feather attr into a state so that it won't NeedsToRender()
01865 
01866     NodePath* pNodePath = new NodePath();
01867     if(!pNodePath)
01868     {
01869         return FALSE;   // nb don't report errors. simply render without feathering if this fails
01870     }
01871 
01872     pNodePath->SetUpPath(pInkPath->GetNumCoords(),12);
01873     pNodePath->InkPath.CopyPathDataFrom(pInkPath);
01874 
01875     if(!MakeLineAttributeCompleteForContouring(pNodePath, this, pBlendMap))
01876     {
01877         // Feather is unrenderable
01878         // Need to de-alloc mem because we will be returning FALSE and
01879         // hence won't be added to the attrmap - therefore no PostDynCreateDeinit
01880         // Set Child pointer to null in case we had partial sucess
01881         // *** Change here if copy attrs from blendmap inside MakeLineAttributeCompleteForContouring
01882         pNodePath->SetChildDangerous(NULL);
01883         delete pNodePath;
01884         return FALSE;
01885     }
01886 
01887     Value.SetLinkedNode(pNodePath);
01888     return TRUE;
01889 }

void AttrFeather::Render RenderRegion pRender  )  [virtual]
 

Render this feather attribute. We do one or two checks for validity of this attr, and then render its attribute-value into the RR.

Author:
Ilan_Copelyn (Xara Group Ltd) <camelotdev@xara.com> , Karim MacDonald
Date:
24/01/2000 , 21/07/2000
Parameters:
pRender the render-region to render into. [INPUTS]
Notes: If you want to customise for different RRs, then override RenderRegion::SetOffscreen and FeatherAttrValue::OffscreenRenderingCompleted.

Returns:
Errors: ERROR3 if we have no linked node at the mo'.
See also: FeatherAttrValue::Render().

Reimplemented from NodeAttribute.

Definition at line 1534 of file fthrattr.cpp.

01535 {
01536     // no feathering for hit-testing, please.
01537     if (pRender->IsHitDetect())
01538         return;
01539 
01540     // Karim 21/07/2000
01541     // Feathers can render into most render regions.
01542     // If a render region can't deal with feathering, then the attribute will only be
01543     // 'rendered' in the RenderRegion sense - ie plonked on the context stack - and
01544     // no attempt will be made to generate offscreen bitmaps and what-not.
01545 
01546     // only bother rendering us if our feather size is non-zero.
01547     if (Value.GetFeatherSize() != 0)
01548     {
01549         // ensure internal pointer is setup for rendering.
01550         if (Value.GetLinkedNode() == NULL)
01551         {
01552             Node* pParent = FindParent();
01553             if (pParent != NULL && pParent->IsAnObject())
01554                 Value.SetLinkedNode((NodeRenderableBounded*) FindParent());
01555 
01556             else
01557             {
01558 //              ERROR3("AttrFeather::Render; No linked node and parent is not an ink-node!");
01559                 return;
01560             }
01561         }
01562         Value.Render(pRender);
01563     }
01564 }

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

Feathering is not supported in certain circumstances listed below Rather than hacking other code to prevent these situations arising I am using this method to prevent feathers causing damage to other nodes.

Feather prevention ;)

This way feathering can be added simply once the individual incompatibilities have been resolved

Notes: Attributes aren't always rendered by the standard render loop (eg DocView::RenderView). Hence this function doesn't catch all cases where feathers will get rendered, and this test needs to be repeated in the corresdponding AttrValue::Render() See RenderRegion::InitDevice() and CCAttrMap::Render() for egs of where these functions will be skipped.

More Notes: Karim 21/07/2000 I have now annihilated all of the render-region checks - rather than do checks on the type of render-region, we'll just let the RR's feather-rendering methods do the job for us. This makes it a *lot* easier to customise for different RR's ;o)

Reimplemented from NodeAttribute.

Definition at line 1807 of file fthrattr.cpp.

01808 {
01809     // Can't feather unless attribute is attached to an object (ie something
01810     // with an inkpath)
01811     if (Value.GetLinkedNode() == NULL && FindParent() == NULL)
01812         return SUBTREE_NORENDER;
01813 
01814     // don't bother rendering if feather size is zero or we're the default attr.
01815     if (Value.GetFeatherSize() == 0 || Value.IsDefaultFlagSet())
01816         return SUBTREE_NORENDER;
01817 
01818     return SUBTREE_ROOTONLY;
01819 }

BOOL AttrFeather::ShouldBeOptimized  )  [virtual]
 

Feathers are layered attributes. Feathering individual members in a group will look visibly different to feathering the entire group (if any of the children overlap) Hence once a feather attribute has been inserted in to the tree it must not be moved around by the optimisation code. However, we don't want zero size feather attributes to be stuck into the tree ever. This function determines when an attribute can be optimised so determined whether we can get rid of rdundant attributes. Hence we allow optimisation to occur in the case where we have a zero width feather.

Called when :- 1) a new node is inserted into the tree 2) a clone is inserted into the tree 3) a node with feathering applied is being grouped with other nodes 4) when a group with feathering applied is being ungrouped

Feathers should never be optimised. This means that they will always be inserted into the tree with each new node created, and not factored out. The default feather after camelot initialises itself (ie on startup) has zero feather width. To prevent the tree becomming filled with lots of superfluous 0 width feather attrs we have an extra check in AttributeManager::ApplyCurrentAttribsToNode.

See also:
AttributeManager::ApplyCurrentAttribsToNode

Reimplemented from NodeAttribute.

Definition at line 1772 of file fthrattr.cpp.

01773 {
01774     // don't want zero width feathers in the tree
01775     if (Value.GetFeatherSize() == 0)
01776         return TRUE;
01777 
01778     return FALSE;
01779 }

Node * AttrFeather::SimpleCopy void   )  [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:
Will_Cowling (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/93
Parameters:
- [INPUTS]
[OUTPUTS] 
Returns:
A copy of the node, or NULL if memory runs 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.

Scope: protected

Reimplemented from NodeAttribute.

Definition at line 1601 of file fthrattr.cpp.

01602 {
01603     AttrFeather* pAttr =  new AttrFeather();
01604     ERRORIF(pAttr==NULL, _R(IDE_NOMORE_MEMORY),NULL);
01605 
01606     CopyNodeContents(pAttr);
01607     return pAttr;
01608 }

void AttrFeather::Transform TransformBase Trans  )  [virtual]
 

Scales the size of the feather as the feathered object is transformed.

Author:
Karim_MacDonald (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/10/2000
Parameters:
Trans the applied transformation. [INPUTS]
The feather size of our FeatherAttrValue will scale. [OUTPUTS]

Reimplemented from NodeRenderable.

Definition at line 1974 of file fthrattr.cpp.

01975 {
01976     static const FIXED16 One(1.0);
01977 
01978     FIXED16 ScaleFactor = Trans.GetScalar();
01979     if (ScaleFactor != One)
01980     {
01981         // Only transform feather width of the transform allows widths to be affected
01982 // NEW FEATURE?
01983 //      if (Trans.TransLines)
01984 //      {
01985             MILLIPOINT FeatherSize = Value.GetFeatherSize();
01986             MILLIPOINT NewSize = INT32(0.5 + fabs(ScaleFactor.MakeDouble() * (double)FeatherSize) );
01987             FeatherSize = (NewSize == 0) ? 1 : NewSize;
01988 
01989             Value.SetFeatherSize(FeatherSize);
01990 //      }
01991     }
01992 
01993     // Always transform the outer path so that the shape appears correctly during solid drags
01994     Path* pOuterContour = Value.GetOuterContour();
01995     if (pOuterContour != NULL)
01996     {
01997         Trans.Transform(pOuterContour->GetCoordArray(), pOuterContour->GetNumCoords());
01998     }
01999 }

BOOL AttrFeather::WritePreChildrenNative BaseCamelotFilter pFilter  )  [virtual]
 

Reimplemented from Node.

Definition at line 2246 of file fthrattr.cpp.

02247 {
02248     return WritePreChildrenWeb(pFilter);
02249 }

BOOL AttrFeather::WritePreChildrenWeb BaseCamelotFilter pFilter  )  [virtual]
 

Writes out a record that represents the node.

> virtual BOOL Node::WritePreChildrenWeb(BaseCamelotFilter* pFilter)

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/5/96
Parameters:
pFilter = ptr to filter to write to [INPUTS]
Returns:
TRUE if the node has written out a record to the filter FALSE otherwise
This function is called before any of the node's children are written to the filter.

If the node writes out a record successfully to the file, it should return TRUE.

If the node chooses not to write itself to the filter (e.g. because it is not appropriate for this filter), then this function should return FALSE.

If an error occurs, the function should call pFilter->GotError(), and return FALSE.

If the node does not want its child nodes to be written automatically, you should make sure you override CanWriteChildrenWeb() so it returns FALSE.

(e.g. this node may choose to save its sub tree itself, so it can choose which of its child nodes should be saved out)

See also:
CanWriteChildrenWeb(), WritePostChildrenWeb()

Reimplemented from Node.

Definition at line 2228 of file fthrattr.cpp.

02229 {
02230     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
02231     CXaraFileRecord Rec(TAG_FEATHER,TAG_FEATHER_SIZE);
02232     BOOL ok = TRUE;
02233     
02234     MILLIPOINT sz = Value.GetFeatherSize();
02235     CProfileBiasGain pProfile(Value.GetProfile());
02236 
02237     ok = Rec.Init();
02238     if (ok) ok = Rec.WriteINT32(sz);
02239     if (ok) ok = Rec.WriteDOUBLE ((double) pProfile.GetBias());
02240     if (ok) ok = Rec.WriteDOUBLE ((double) pProfile.GetGain());
02241     if (ok) ok = pFilter->Write(&Rec);
02242 
02243     return ok;
02244 }


Member Data Documentation

FeatherAttrValue AttrFeather::Value
 

Definition at line 385 of file fthrattr.h.


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