00001 // $Id: ndbrshpt.cpp 751 2006-03-31 15:43:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 // implementation of NodeBrushPath 00100 00101 #include "camtypes.h" 00102 #include "ndbrshpt.h" 00103 #include "pathproc.h" 00104 #include "ndbrshmk.h" 00105 #include "nodebrsh.h" 00106 CC_IMPLEMENT_DYNCREATE(NodeBrushPath, NodeBlendPath); 00107 00108 00109 /********************************************************************************************* 00110 00111 > NodeBrushPath::NodeBrushPath() 00112 00113 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00114 Created: 6/10/99 00115 Purpose: This constructor creates a NodeBrushPath linked to no other, with all status 00116 flags false and an uninitialised bounding rectangle. 00117 00118 **********************************************************************************************/ 00119 00120 00121 NodeBrushPath::NodeBrushPath(): NodeBlendPath() 00122 { 00123 m_pCachedPointsAtDistance = NULL; 00124 // Reuse the "Destroy cache" call 00125 DestroyCachedInformation(); 00126 m_bDrawingBrush = FALSE; 00127 m_pProcessPath = NULL; 00128 00129 } 00130 00131 /*********************************************************************************************** 00132 00133 > void NodeBrushPath::NodeBrushPath 00134 ( 00135 Node* ContextNode, 00136 AttachNodeDirection Direction, 00137 BOOL Locked = FALSE, 00138 BOOL Mangled = FALSE, 00139 BOOL Marked = FALSE, 00140 BOOL Selected = FALSE, 00141 ) 00142 00143 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00144 Created: 6/10/99 00145 Inputs: ContextNode: Pointer to a node which this node is to be attached to. 00146 00147 Direction: 00148 00149 Specifies the direction in which this node is to be attached to the 00150 ContextNode. The values this variable can take are as follows: 00151 00152 PREV : Attach node as a previous sibling of the context node 00153 NEXT : Attach node as a next sibling of the context node 00154 FIRSTCHILD: Attach node as the first child of the context node 00155 LASTCHILD : Attach node as a last child of the context node 00156 00157 The remaining inputs specify the status of the node: 00158 00159 Locked: Is node locked ? 00160 Mangled: Is node mangled ? 00161 Marked: Is node marked ? 00162 Selected: Is node selected ? 00163 00164 Outputs: - 00165 Returns: - 00166 Purpose: This method initialises the node and links it to ContextNode in the 00167 direction specified by Direction. All necessary tree links are 00168 updated. 00169 00170 Errors: An assertion error will occur if ContextNode is NULL 00171 00172 00173 ***********************************************************************************************/ 00174 00175 NodeBrushPath::NodeBrushPath(Node* ContextNode, 00176 AttachNodeDirection Direction, 00177 BOOL Locked, 00178 BOOL Mangled, 00179 BOOL Marked, 00180 BOOL Selected 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 } 00190 00191 /********************************************************************************************* 00192 00193 > NodeBrushPath::~NodeBrushPath() 00194 00195 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00196 Created: 6/10/99 00197 Purpose: Destructor for NodeBrushPath. 00198 00199 **********************************************************************************************/ 00200 00201 NodeBrushPath::~NodeBrushPath() 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 } 00212 00213 00214 /*********************************************************************************************** 00215 00216 > virtual Node* NodeBrushPath::SimpleCopy() 00217 00218 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00219 Created: 6/10/99 00220 Returns: Pointer to a Node 00221 Purpose: Makes a copy of all the data in the node 00222 00223 ***********************************************************************************************/ 00224 00225 Node* NodeBrushPath::SimpleCopy() 00226 { 00227 NodeBrushPath* NodeCopy = new NodeBrushPath(); 00228 if (NodeCopy) 00229 CopyNodeContents(NodeCopy); 00230 00231 return NodeCopy; 00232 } 00233 00234 00235 /*********************************************************************************************** 00236 00237 > void NodeBrushPath::CopyNodeContents(NodeBrushPath* NodeCopy) 00238 00239 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00240 Created: 6/10/99 00241 Inputs: NodeCopy - The node to copy 00242 Purpose: Copies the data in the node by first calling the base class to get it to 00243 copy its stuff, and then copying its own stuff 00244 Scope: protected 00245 SeeAlso: NodeRenderableInk::CopyNodeContents 00246 00247 ***********************************************************************************************/ 00248 00249 void NodeBrushPath::CopyNodeContents( NodeBrushPath* NodeCopy) 00250 { 00251 NodePath::CopyNodeContents( NodeCopy ); 00252 //Copy contents specific to derived class here 00253 } 00254 00255 00256 00257 /*********************************************************************************************** 00258 > void NodeBrushPath::PolyCopyNodeContents(NodeRenderable* pNodeCopy) 00259 00260 Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com> 00261 Created: 18/12/2003 00262 Outputs: - 00263 Purpose: Polymorphically copies the contents of this node to another 00264 Errors: An assertion failure will occur if NodeCopy is NULL 00265 Scope: protected 00266 00267 ***********************************************************************************************/ 00268 00269 void NodeBrushPath::PolyCopyNodeContents(NodeRenderable* pNodeCopy) 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 } 00277 00278 00279 00280 /******************************************************************************************** 00281 00282 > virtual BOOL NodeBrushPath::WritePreChildrenWeb(BaseCamelotFilter* pFilter) 00283 00284 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00285 Created: 7/10/99 00286 Inputs: pFilter = ptr to the filter 00287 Returns: TRUE if record is written, FALSE if not 00288 Purpose: Writes the nodebrushpath path record to the filter 00289 SeeAlso: - 00290 00291 ********************************************************************************************/ 00292 00293 BOOL NodeBrushPath::WritePreChildrenWeb(BaseCamelotFilter* pFilter) 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 } 00325 00326 /******************************************************************************************** 00327 00328 > virtual BOOL NodeBrushPath::WritePreChildrenNative(BaseCamelotFilter* pFilter) 00329 00330 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00331 Created: 7/10/99 00332 Inputs: pFilter = ptr to the filter 00333 Returns: TRUE if record is written, FALSE if not 00334 Purpose: Writes the nodebrushpath path record to the filter 00335 SeeAlso: - 00336 00337 ********************************************************************************************/ 00338 00339 BOOL NodeBrushPath::WritePreChildrenNative(BaseCamelotFilter* pFilter) 00340 { 00341 return WritePreChildrenWeb(pFilter); 00342 } 00343 00344 00345 00346 /******************************************************************************************** 00347 > void NodeBrushPath::SetPointAtDistance(MILLIPOINT Distance, DocCoord* pPoint) 00348 00349 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00350 Created: 7/10/99 00351 Inputs: Distance = a length along the path 00352 Outputs: pPoint = the coordinate of the point that distance along the path 00353 Returns: - 00354 Purpose: Sets the coordinate of a point a certain distance along this path 00355 in the cached points map 00356 ********************************************************************************************/ 00357 00358 void NodeBrushPath::SetPointAtDistance(MILLIPOINT Distance, DocCoord Point) 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 } 00376 00377 00378 00379 /******************************************************************************************** 00380 > INT32 NodeBrushPath::GetNumberOfSteps() 00381 00382 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00383 Created: 7/10/99 00384 Inputs: - 00385 Outputs: - 00386 Returns: the number of steps in the nodebrushpath, given the step distance 00387 Purpose: as above 00388 00389 ********************************************************************************************/ 00390 00391 INT32 NodeBrushPath::GetNumberOfSteps() 00392 { 00393 return m_NumSteps; 00394 } 00395 00396 00397 00398 /******************************************************************************************** 00399 > void NodeBrushPath::SetNumberOfSteps(INT32 Steps) 00400 00401 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00402 Created: 7/10/99 00403 Inputs: Steps - the number to set 00404 Outputs: - 00405 Returns: - 00406 Purpose: sets the number of steps in the nodeblendpath 00407 00408 ********************************************************************************************/ 00409 00410 void NodeBrushPath::SetNumberOfSteps(INT32 Steps) 00411 { 00412 m_NumSteps = Steps; 00413 } 00414 00415 00416 /******************************************************************************************** 00417 > void NodeBrushPath::StartedBrush() 00418 00419 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00420 Created: 7/10/99 00421 Inputs: - 00422 Outputs: - 00423 Returns: - 00424 Purpose: informs the nodebrushpath that the brush is being drawn 00425 00426 ********************************************************************************************/ 00427 00428 void NodeBrushPath::StartedBrush() 00429 { 00430 // ResetPathProcCache(); 00431 m_bDrawingBrush = TRUE; 00432 } 00433 00434 00435 00436 /******************************************************************************************** 00437 > void NodeBrushPath::StoppedBrush() 00438 00439 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00440 Created: 7/10/99 00441 Inputs: - 00442 Outputs: - 00443 Returns: - 00444 Purpose: informs the nodebrushpath that the brush has finished being drawn 00445 00446 ********************************************************************************************/ 00447 00448 void NodeBrushPath::StoppedBrush() 00449 { 00450 m_bDrawingBrush = FALSE; 00451 ResetPathProcCache(); 00452 if (m_pProcessPath != NULL) 00453 { 00454 delete m_pProcessPath; 00455 m_pProcessPath = NULL; 00456 } 00457 } 00458 00459 00460 00461 /******************************************************************************************** 00462 00463 > DocRect NodeBrushPath::GetBoundingRect(BOOL DontUseAttrs=FALSE, BOOL HitTest=FALSE) 00464 00465 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00466 Created: 19/9/99 00467 Inputs: DontUseAttrs - TRUE if you don't want to use the nodes attrs to calculate 00468 the bounding rect (defaults will be used). Defaults to FALSE. 00469 HitTest - TRUE if being called during HitTest 00470 Returns: bounding rectangle of the inkpath 00471 Purpose: Returns the bounding rectangle of the coordinates of the path 00472 00473 ********************************************************************************************/ 00474 00475 DocRect NodeBrushPath::GetBoundingRect() 00476 { 00477 //TRACEUSER( "Diccon", _T("Getting BRect, currently %d\n"), IsBoundingRectValid); 00478 return NodePath::GetBoundingRect(); 00479 } 00480 00481 00482 /******************************************************************************************** 00483 00484 > void NodeBrushPath::AddPointToBoundingRect(DocCoord Point) 00485 00486 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00487 Created: 19/9/99 00488 Inputs: Point - coordinate to include in the bounding rect 00489 Returns: - 00490 Purpose: So that we can generate the bounding rect of the path as it is drawn 00491 this function allows us to add a single point to the bounding rectangle 00492 00493 ********************************************************************************************/ 00494 00495 void NodeBrushPath::IncludePointInBoundingRect(DocCoord Point) 00496 { 00497 BoundingRectangle.IncludePoint(Point); 00498 } 00499 00500 00501 /******************************************************************************************** 00502 00503 > void NodeBrushPath::Render( RenderRegion* pRender ) 00504 00505 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00506 Created: 9/11/99 00507 Inputs: pRender - A Pointer to the current RenderRegion 00508 Purpose: If the brush is selected then the path is rendered, otherwise not 00509 00510 ********************************************************************************************/ 00511 00512 void NodeBrushPath::Render( RenderRegion* pRender ) 00513 { 00514 pRender -> DrawPath( &InkPath ); 00515 } 00516 00517 00518 /******************************************************************************************** 00519 00520 > void NodeBrushPath::RenderObjectBlobs(RenderRegion* pRender) 00521 00522 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00523 Created: 12/11/99 00524 Inputs: pRender - The region to render the blobs into 00525 Purpose: Draws the actual path, so that it is only seen when selected 00526 00527 ********************************************************************************************/ 00528 00529 void NodeBrushPath::RenderObjectBlobs(RenderRegion* pRender) 00530 { 00531 pRender -> DrawPath( &InkPath ); 00532 } 00533 00534 00535 /******************************************************************************************** 00536 00537 > void NodeBrushPath::RenderTinyBlobs(RenderRegion* pRender) 00538 00539 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00540 Created: 12/11/99 00541 Inputs: pRender - The region to render the blobs into 00542 Purpose: Draws the actual path, so that it is only seen when selected 00543 00544 ********************************************************************************************/ 00545 00546 void NodeBrushPath::RenderTinyBlobs(RenderRegion* pRender) 00547 { 00548 //pRender -> DrawPath( &InkPath ); 00549 } 00550 00551 00552 /******************************************************************************************** 00553 00554 > void NodeBrushPath::RenderEorDrag( RenderRegion* pRender ) 00555 00556 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00557 Created: 9/11/99 00558 Inputs: pRender - A Pointer to the current RenderRegion 00559 Purpose: Renders a version of the path for EORed dragging of shapes. 00560 SeeAlso: NodePath::Render; NodeRenderableInk::RenderEorDrag 00561 00562 ********************************************************************************************/ 00563 00564 void NodeBrushPath::RenderEorDrag( RenderRegion* pRender ) 00565 { 00566 pRender -> DrawPath( &InkPath ); 00567 } 00568 00569 00570 00571 00572 /******************************************************************************************** 00573 00574 > virtual void NodeBrushPath::Transform( TransformBase& Trans ) 00575 00576 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00577 Created: 28/11/99 00578 Inputs: Trans - The transform to be applied to the path 00579 Purpose: Will Transform all the coords in the path with the transform 00580 provided 00581 SeeAlso: NodeRenderableInk::Transform() 00582 00583 ********************************************************************************************/ 00584 00585 void NodeBrushPath::Transform(TransformBase &Trans) 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 } 00618 00619 /******************************************************************************************** 00620 > BOOL NodeBrushPath::GetPointAtDistance(MILLIPOINT Distance, DocCoord* pPoint, 00621 double* pTangent, BOOL UseCache = FALSE) 00622 00623 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00624 Created: 30/4/99 00625 Inputs: Distance = a length along the path 00626 Outputs: pPoint = the coordinate of the point that distance along the path 00627 pTangent = tangent at this point (can be NULL) 00628 UseCache - whether or not to use the cached path processor (don't unless 00629 a) you're sure it hasn't been deleted and b) you only want consecutive points). 00630 00631 Returns: TRUE/FALSE for success/failure 00632 Purpose: Gets the coordinate of a point a certain distance along this path 00633 Calls the underlying Path class function 00634 This is identical to the version in ndbldpth.cpp except that this uses 00635 the cached version of path::Getpointatdistance 00636 ********************************************************************************************/ 00637 00638 BOOL NodeBrushPath::GetPointAtDistance(MILLIPOINT Distance, DocCoord* pPoint, 00639 double* pTangent, BOOL UseCache) 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 } 00707 00708 00709 /******************************************************************************************** 00710 00711 > void NodeBrushPath::ResetPathProcCache() 00712 00713 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00714 Created: 28/11/99 00715 Inputs: - 00716 Purpose: To reset the cache used by the inkpath member, call this if you are going to 00717 alter the path in any way 00718 00719 00720 ********************************************************************************************/ 00721 00722 void NodeBrushPath::ResetPathProcCache() 00723 { 00724 //InkPath.ResetCoordsProcessed(); 00725 00726 } 00727 00728 00729 /******************************************************************************************** 00730 00731 > BOOL NodeBrushPath::InitialisePathProcessor() 00732 00733 Author: Diccon_Yamanaka (Xara Group Ltd) <camelotdev@xara.com> 00734 Created: 28/11/99 00735 Inputs: - 00736 Purpose: To create a new path processor object 00737 SeeAlso: - 00738 00739 ********************************************************************************************/ 00740 00741 BOOL NodeBrushPath::InitialisePathProcessor() 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 } 00755 00756 00757