NodeBrushPath Class Reference

The NodeBrushMaker class. More...

#include <ndbrshpt.h>

Inheritance diagram for NodeBrushPath:

NodeBlendPath NodePath NodeRenderableInk NodeRenderableBounded NodeRenderable Node CCObject SimpleCCObject List of all members.

Public Member Functions

 NodeBrushPath ()
 This constructor creates a NodeBrushPath linked to no other, with all status flags false and an uninitialised bounding rectangle.
 ~NodeBrushPath ()
 Destructor for NodeBrushPath.
 NodeBrushPath (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.
virtual NodeSimpleCopy ()
 Makes a copy of all the data in the node.
virtual BOOL WritePreChildrenWeb (BaseCamelotFilter *pFilter)
 Writes the nodebrushpath path record to the filter.
virtual BOOL WritePreChildrenNative (BaseCamelotFilter *pFilter)
 Writes the nodebrushpath path record to the filter.
virtual void RenderEorDrag (RenderRegion *)
 Renders a version of the path for EORed dragging of shapes.
virtual void Render (RenderRegion *pRender)
 If the brush is selected then the path is rendered, otherwise not.
virtual void RenderObjectBlobs (RenderRegion *pRender)
 Draws the actual path, so that it is only seen when selected.
virtual void RenderTinyBlobs (RenderRegion *pRender)
 Draws the actual path, so that it is only seen when selected.
virtual DocRect GetBoundingRect ()
 Returns the bounding rectangle of the coordinates of the path.
virtual void Transform (TransformBase &Trans)
 Will Transform all the coords in the path with the transform provided.
void SetPointAtDistance (MILLIPOINT Distance, DocCoord Point)
 Sets the coordinate of a point a certain distance along this path in the cached points map.
INT32 GetNumberOfSteps ()
 as above
void SetNumberOfSteps (INT32 Steps)
 sets the number of steps in the nodeblendpath
void IncludePointInBoundingRect (DocCoord Point)
 So that we can generate the bounding rect of the path as it is drawn this function allows us to add a single point to the bounding rectangle.
BOOL GetPointAtDistance (MILLIPOINT Dist, DocCoord *pPoint, double *pTangent, BOOL UseCache=FALSE)
 Gets the coordinate of a point a certain distance along this path Calls the underlying Path class function This is identical to the version in ndbldpth.cpp except that this uses the cached version of path::Getpointatdistance.
void ResetPathProcCache ()
 To reset the cache used by the inkpath member, call this if you are going to alter the path in any way.
void StartedBrush ()
 informs the nodebrushpath that the brush is being drawn
void StoppedBrush ()
 informs the nodebrushpath that the brush has finished being drawn
BOOL InitialisePathProcessor ()
 To create a new path processor object.
virtual void PolyCopyNodeContents (NodeRenderable *pNodeCopy)
 Polymorphically copies the contents of this node to another.

Protected Member Functions

void CopyNodeContents (NodeBrushPath *NodeCopy)
 Copies the data in the node by first calling the base class to get it to copy its stuff, and then copying its own stuff Scope: protected.

Protected Attributes

ProcessPathDistancem_pProcessPath
INT32 m_NumSteps
BOOL m_bDrawingBrush

Detailed Description

The NodeBrushMaker class.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/10/99

Definition at line 121 of file ndbrshpt.h.


Constructor & Destructor Documentation

NodeBrushPath::NodeBrushPath  ) 
 

This constructor creates a NodeBrushPath linked to no other, with all status flags false and an uninitialised bounding rectangle.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99

Definition at line 121 of file ndbrshpt.cpp.

00121                             : NodeBlendPath()
00122 {
00123     m_pCachedPointsAtDistance = NULL;
00124     // Reuse the "Destroy cache" call
00125     DestroyCachedInformation();
00126     m_bDrawingBrush = FALSE;
00127     m_pProcessPath = NULL;
00128 
00129 }

NodeBrushPath::~NodeBrushPath  ) 
 

Destructor for NodeBrushPath.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99

Definition at line 201 of file ndbrshpt.cpp.

00202 {
00203     // Reuse the "Destroy cache" call
00204     DestroyCachedInformation();
00205 
00206     if (m_pProcessPath != NULL)
00207     {
00208         delete m_pProcessPath;
00209         m_pProcessPath = NULL;
00210     }
00211 }

NodeBrushPath::NodeBrushPath 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:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99
Parameters:
ContextNode,: Pointer to a node which this node is to be attached to. [INPUTS]
Direction:

Specifies the direction in which this 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 ?

Parameters:
- [OUTPUTS]
Returns:
-

Errors: An assertion error will occur if ContextNode is NULL

Definition at line 175 of file ndbrshpt.cpp.

00181                 :NodeBlendPath(ContextNode, Direction, Locked, Mangled, Marked, Selected) 
00182 { 
00183     m_pCachedPointsAtDistance = NULL;
00184     // Reuse the "Destroy cache" call
00185     DestroyCachedInformation();
00186     m_bDrawingBrush = FALSE;
00187     m_pProcessPath = NULL;
00188 
00189 } 


Member Function Documentation

void NodeBrushPath::CopyNodeContents NodeBrushPath NodeCopy  )  [protected]
 

Copies the data in the node by first calling the base class to get it to copy its stuff, and then copying its own stuff Scope: protected.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99
Parameters:
NodeCopy - The node to copy [INPUTS]
See also:
NodeRenderableInk::CopyNodeContents

Definition at line 249 of file ndbrshpt.cpp.

00250 {
00251     NodePath::CopyNodeContents( NodeCopy );
00252     //Copy contents specific to derived class here
00253 }

DocRect NodeBrushPath::GetBoundingRect  )  [virtual]
 

Returns the bounding rectangle of the coordinates of the path.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/9/99
Parameters:
DontUseAttrs - TRUE if you don't want to use the nodes attrs to calculate [INPUTS] the bounding rect (defaults will be used). Defaults to FALSE. HitTest - TRUE if being called during HitTest
Returns:
bounding rectangle of the inkpath

Definition at line 475 of file ndbrshpt.cpp.

00476 {
00477     //TRACEUSER( "Diccon", _T("Getting BRect, currently %d\n"), IsBoundingRectValid);
00478     return NodePath::GetBoundingRect();
00479 }

INT32 NodeBrushPath::GetNumberOfSteps  ) 
 

as above

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/10/99
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
the number of steps in the nodebrushpath, given the step distance

Definition at line 391 of file ndbrshpt.cpp.

00392 {
00393     return m_NumSteps;
00394 }

BOOL NodeBrushPath::GetPointAtDistance MILLIPOINT  Distance,
DocCoord pPoint,
double *  pTangent,
BOOL  UseCache = FALSE
 

Gets the coordinate of a point a certain distance along this path Calls the underlying Path class function This is identical to the version in ndbldpth.cpp except that this uses the cached version of path::Getpointatdistance.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/4/99
Parameters:
Distance = a length along the path [INPUTS]
pPoint = the coordinate of the point that distance along the path [OUTPUTS] pTangent = tangent at this point (can be NULL) UseCache - whether or not to use the cached path processor (don't unless a) you're sure it hasn't been deleted and b) you only want consecutive points).
Returns:
TRUE/FALSE for success/failure

Definition at line 638 of file ndbrshpt.cpp.

00640 {
00641     ERROR2IF(pPoint == NULL,FALSE,"NULL pPoint param");
00642 
00643     BOOL Found = FALSE;
00644 
00645 
00646     CPathPointInfo  PointInfo;
00647 
00648     if (m_pCachedPointsAtDistance == NULL)
00649     {
00650         m_pCachedPointsAtDistance = new CMap<MILLIPOINT,MILLIPOINT&,CPathPointInfo,CPathPointInfo&>;
00651 //      if (m_pCachedPointsAtDistance != NULL)
00652 //          m_pCachedPointsAtDistance->InitHashTable(1277);     // Init hash table size to a suitably large prime number
00653     }
00654 
00655     if (m_pCachedPointsAtDistance != NULL)
00656     {
00657     
00658         Found = m_pCachedPointsAtDistance->Lookup(Distance,PointInfo);
00659         //if (Found)
00660     //  TRACEUSER( "Diccon", _T("Point %d, %d found in cache\n"), PointInfo.m_Point.x, PointInfo.m_Point.y);
00661     }
00662 
00663     if (!Found)
00664     {   
00665 
00666         // if we are drawing the brush then use the cached path processor, otherwise
00667         // use the normal one
00668         if (UseCache)
00669         {
00670     
00671             BOOL PointFound = FALSE;
00672             INT32 NumCoords;
00673             NumCoords = m_pProcessPath->GetCoordAndTangentWithCache( &PointInfo.m_Point, &PointInfo.m_Tangent, 
00674                                                                     &PointFound, Distance ,&InkPath);
00675             if ((NumCoords != -1) && PointFound)
00676             {
00677 
00678                 if (m_pCachedPointsAtDistance != NULL)
00679                     m_pCachedPointsAtDistance->SetAt(Distance,PointInfo);
00680                 Found = TRUE;   
00681             }   
00682         }
00683         else
00684         {
00685             if (InkPath.GetPointAtDistance(Distance,&PointInfo.m_Point,&PointInfo.m_Tangent))
00686             {
00687                 if (m_pCachedPointsAtDistance != NULL)
00688                     m_pCachedPointsAtDistance->SetAt(Distance,PointInfo);
00689         //      TRACEUSER( "Diccon", _T("Point %d, %d found from line\n"), PointInfo.m_Point.x, PointInfo.m_Point.y);
00690                 Found = TRUE;
00691             }
00692         }
00693     }
00694 
00695     if (Found)
00696     {
00697         *pPoint = PointInfo.m_Point;
00698         if (pTangent)
00699             *pTangent = PointInfo.m_Tangent;
00700     }
00701 
00702 
00703 //  if (Found == FALSE)
00704     //  TRACEUSER( "Diccon", _T("Not found at distance %d\n"), Distance);
00705     return Found;
00706 }

void NodeBrushPath::IncludePointInBoundingRect DocCoord  Point  ) 
 

So that we can generate the bounding rect of the path as it is drawn this function allows us to add a single point to the bounding rectangle.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/9/99
Parameters:
Point - coordinate to include in the bounding rect [INPUTS]
Returns:
-

Definition at line 495 of file ndbrshpt.cpp.

00496 {
00497     BoundingRectangle.IncludePoint(Point);
00498 }

BOOL NodeBrushPath::InitialisePathProcessor  ) 
 

To create a new path processor object.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/11/99
Parameters:
- [INPUTS]
See also:
-

Definition at line 741 of file ndbrshpt.cpp.

00742 {
00743     if (m_pProcessPath != NULL)
00744     {
00745         delete m_pProcessPath;
00746         m_pProcessPath = NULL;
00747     }
00748 
00749     //m_pProcessPath = new ProcessPathDistance(64);
00750 
00751     //ERROR2IF(m_pProcessPath == NULL, FALSE, "Unable to allocate ProcessPathDistance object");
00752 
00753     return TRUE;
00754 }

void NodeBrushPath::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 NodeBlendPath.

Definition at line 269 of file ndbrshpt.cpp.

00270 {
00271     ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
00272     ENSURE(IS_A(pNodeCopy, NodeBrushPath), "PolyCopyNodeContents given wrong dest node type");
00273 
00274     if (IS_A(pNodeCopy, NodeBrushPath))
00275         CopyNodeContents((NodeBrushPath*)pNodeCopy);
00276 }

void NodeBrushPath::Render RenderRegion pRender  )  [virtual]
 

If the brush is selected then the path is rendered, otherwise not.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/11/99
Parameters:
pRender - A Pointer to the current RenderRegion [INPUTS]

Reimplemented from NodeBlendPath.

Definition at line 512 of file ndbrshpt.cpp.

00513 {   
00514     pRender -> DrawPath( &InkPath );
00515 }

void NodeBrushPath::RenderEorDrag RenderRegion pRender  )  [virtual]
 

Renders a version of the path for EORed dragging of shapes.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/11/99
Parameters:
pRender - A Pointer to the current RenderRegion [INPUTS]
See also:
NodePath::Render; NodeRenderableInk::RenderEorDrag

Reimplemented from NodeBlendPath.

Definition at line 564 of file ndbrshpt.cpp.

00565 {
00566     pRender -> DrawPath( &InkPath );
00567 }

void NodeBrushPath::RenderObjectBlobs RenderRegion pRender  )  [virtual]
 

Draws the actual path, so that it is only seen when selected.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/11/99
Parameters:
pRender - The region to render the blobs into [INPUTS]

Reimplemented from NodeBlendPath.

Definition at line 529 of file ndbrshpt.cpp.

00530 {
00531     pRender -> DrawPath( &InkPath );
00532 }

void NodeBrushPath::RenderTinyBlobs RenderRegion pRender  )  [virtual]
 

Draws the actual path, so that it is only seen when selected.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/11/99
Parameters:
pRender - The region to render the blobs into [INPUTS]

Reimplemented from NodePath.

Definition at line 546 of file ndbrshpt.cpp.

00547 {
00548     //pRender -> DrawPath( &InkPath );
00549 }

void NodeBrushPath::ResetPathProcCache  ) 
 

To reset the cache used by the inkpath member, call this if you are going to alter the path in any way.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/11/99
Parameters:
- [INPUTS]

Definition at line 722 of file ndbrshpt.cpp.

00723 {
00724     //InkPath.ResetCoordsProcessed();
00725 
00726 }

void NodeBrushPath::SetNumberOfSteps INT32  Steps  ) 
 

sets the number of steps in the nodeblendpath

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/10/99
Parameters:
Steps - the number to set [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 410 of file ndbrshpt.cpp.

00411 {
00412     m_NumSteps = Steps;
00413 }

void NodeBrushPath::SetPointAtDistance MILLIPOINT  Distance,
DocCoord  Point
 

Sets the coordinate of a point a certain distance along this path in the cached points map.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/10/99
Parameters:
Distance = a length along the path [INPUTS]
pPoint = the coordinate of the point that distance along the path [OUTPUTS]
Returns:
-

Definition at line 358 of file ndbrshpt.cpp.

00359 {
00360     CPathPointInfo  PointInfo;
00361 
00362     if (m_pCachedPointsAtDistance == NULL)
00363     {
00364         m_pCachedPointsAtDistance = new CMap<MILLIPOINT,MILLIPOINT&,CPathPointInfo,CPathPointInfo&>;
00365 //      if (m_pCachedPointsAtDistance != NULL)
00366 //          m_pCachedPointsAtDistance->InitHashTable(1277);     // Init hash table size to a suitably large prime number
00367     }
00368 
00369 
00370     PointInfo.m_Point = Point;
00371 
00372     if (m_pCachedPointsAtDistance != NULL)
00373         m_pCachedPointsAtDistance->SetAt(Distance,PointInfo);
00374 
00375 }

Node * NodeBrushPath::SimpleCopy void   )  [virtual]
 

Makes a copy of all the data in the node.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/99
Returns:
Pointer to a Node

Reimplemented from NodeBlendPath.

Definition at line 225 of file ndbrshpt.cpp.

00226 {
00227     NodeBrushPath* NodeCopy = new NodeBrushPath();
00228     if (NodeCopy)
00229         CopyNodeContents(NodeCopy);
00230     
00231     return NodeCopy;
00232 }            

void NodeBrushPath::StartedBrush  ) 
 

informs the nodebrushpath that the brush is being drawn

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/10/99
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 428 of file ndbrshpt.cpp.

00429 {
00430 //  ResetPathProcCache();
00431     m_bDrawingBrush = TRUE;
00432 }

void NodeBrushPath::StoppedBrush  ) 
 

informs the nodebrushpath that the brush has finished being drawn

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/10/99
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 448 of file ndbrshpt.cpp.

00449 {
00450     m_bDrawingBrush = FALSE;
00451     ResetPathProcCache();
00452     if (m_pProcessPath != NULL)
00453     {
00454         delete m_pProcessPath;
00455         m_pProcessPath = NULL;
00456     }
00457 }

void NodeBrushPath::Transform TransformBase Trans  )  [virtual]
 

Will Transform all the coords in the path with the transform provided.

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/11/99
Parameters:
Trans - The transform to be applied to the path [INPUTS]
See also:
NodeRenderableInk::Transform()

Reimplemented from NodePath.

Definition at line 585 of file ndbrshpt.cpp.

00586 {
00587     // Change all the coords
00588     Trans.Transform( (DocCoord*)InkPath.GetCoordArray(), InkPath.GetNumCoords() );
00589 
00590     // and keep the bounding rectangle up to date.
00591     InvalidateBoundingRect();
00592 
00593     // Transform all the children...
00594     TransformChildren(Trans);
00595 
00596     // clear out the cache
00597     DestroyCachedInformation(); 
00598 
00599     // as we are going to need to recalculate all the points try
00600     // to get the path processor back in action, don't worry if it fails though
00601     if (InitialisePathProcessor())
00602     {
00603         // we got it, so tell the NBM to ask for the cache
00604         Node* pParent = this->FindParent();
00605         if (pParent != NULL)
00606         {
00607             NodeBrushMaker* pMaker = (NodeBrushMaker*)pParent->FindFirstChild(CC_RUNTIME_CLASS(NodeBrushMaker));
00608             if (pMaker != NULL)
00609                 pMaker->SetUsePathCache(FALSE);
00610         }
00611         else
00612         {
00613             delete m_pProcessPath;
00614             m_pProcessPath = NULL;
00615         }
00616     }
00617 }

BOOL NodeBrushPath::WritePreChildrenNative BaseCamelotFilter pFilter  )  [virtual]
 

Writes the nodebrushpath path record to the filter.

> virtual BOOL NodeBrushPath::WritePreChildrenNative(BaseCamelotFilter* pFilter)

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/10/99
Parameters:
pFilter = ptr to the filter [INPUTS]
Returns:
TRUE if record is written, FALSE if not
See also:
-

Reimplemented from NodeBlendPath.

Definition at line 339 of file ndbrshpt.cpp.

00340 {
00341     return WritePreChildrenWeb(pFilter);
00342 }

BOOL NodeBrushPath::WritePreChildrenWeb BaseCamelotFilter pFilter  )  [virtual]
 

Writes the nodebrushpath path record to the filter.

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

Author:
Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com>
Date:
7/10/99
Parameters:
pFilter = ptr to the filter [INPUTS]
Returns:
TRUE if record is written, FALSE if not
See also:
-

Reimplemented from NodeBlendPath.

Definition at line 293 of file ndbrshpt.cpp.

00294 {
00295     ERROR2IF(pFilter == NULL,FALSE,"NULL filter param");
00296 
00297     BOOL ok = TRUE;
00298     /*
00299     INT32 NumCoords = InkPath.GetNumCoords();
00300     INT32 RecordSize = sizeof(INT32)+(sizeof(PathVerb)*NumCoords)+(sizeof(DocCoord)*NumCoords);
00301 
00302     CamelotFileRecord Rec(pFilter,TAG_BLEND_PATH,RecordSize);
00303 
00304     BOOL ok = Rec.Init();
00305 
00306     if (ok) ok = Rec.WritePath(&InkPath);
00307     if (ok) ok = pFilter->Write(&Rec);
00308     if (ok)
00309     {
00310         CamelotFileRecord FilledRec(pFilter, TAG_NODEBLENDPATH_FILLED, sizeof(INT32));
00311         
00312         ok = FilledRec.Init();
00313         if (ok)
00314         {
00315             INT32 Filled = InkPath.IsFilled;
00316             ok = FilledRec.WriteINT32(Filled);
00317             if (ok) ok = pFilter->Write(&FilledRec);
00318         }
00319     }
00320     if (!ok)
00321         pFilter->GotError(_R(IDE_FILE_WRITE_ERROR));
00322 */
00323     return ok;
00324 }


Member Data Documentation

BOOL NodeBrushPath::m_bDrawingBrush [protected]
 

Definition at line 173 of file ndbrshpt.h.

INT32 NodeBrushPath::m_NumSteps [protected]
 

Definition at line 172 of file ndbrshpt.h.

ProcessPathDistance* NodeBrushPath::m_pProcessPath [protected]
 

Definition at line 171 of file ndbrshpt.h.


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