RangeList Class Reference

Holds a list of ranges. This is used to keep track when importing a file and preserving the layer information, and the import was initiated via drag and drop. When the import has finished, the bounding box of all the nodes on all the ranges is found, and then the all the nodes in all the ranges are centred on the drop point. More...

#include <epsfiltr.h>

Inheritance diagram for RangeList:

List CCObject SimpleCCObject List of all members.

Public Member Functions

BOOL AddRange (Node *pFirst, Node *pLast)
 Adds another range to the range list. All nodes from pFirst to pLast are inclusively added to the range.
DocRect GetBoundingRect ()
 Goes through all nodes in all the ranges in this RangeList, and unions all the bounding boxes together. It uses the simple algorithm, which does not take account of the attributes applied to the nodes - i.e. it only gives an approximation (hence this function can result in bounding boxes being in the tree which are not entirely accurate).
void Transform (TransformBase &)
 Transforms all the nodes in all the ranges of this range list using the transform object given.

Private Member Functions

 CC_DECLARE_MEMDUMP (RangeList)

Detailed Description

Holds a list of ranges. This is used to keep track when importing a file and preserving the layer information, and the import was initiated via drag and drop. When the import has finished, the bounding box of all the nodes on all the ranges is found, and then the all the nodes in all the ranges are centred on the drop point.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/09/94
See also:
OpDroppedFiles

Definition at line 302 of file epsfiltr.h.


Member Function Documentation

BOOL RangeList::AddRange Node pFirst,
Node pLast
 

Adds another range to the range list. All nodes from pFirst to pLast are inclusively added to the range.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/09/94
Parameters:
pFirst,pLast - the first and last nodes in the range. [INPUTS]
Returns:
TRUE if the range was added ok; FALSE if not.
See also:
Range

Definition at line 249 of file epsfiltr.cpp.

00250 {
00251     // Get a new range
00252     RangeListItem *pItem = new RangeListItem(pFirst, pLast);
00253     if (pItem == NULL)
00254         // Out of memory
00255         return FALSE;
00256 
00257     // Add it to the list and return success
00258     AddTail(pItem);
00259     return TRUE;
00260 }

RangeList::CC_DECLARE_MEMDUMP RangeList   )  [private]
 

DocRect RangeList::GetBoundingRect  ) 
 

Goes through all nodes in all the ranges in this RangeList, and unions all the bounding boxes together. It uses the simple algorithm, which does not take account of the attributes applied to the nodes - i.e. it only gives an approximation (hence this function can result in bounding boxes being in the tree which are not entirely accurate).

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/09/94
Returns:
The union of the bounding boxes of all nodes in this range list.
See also:
RangeList

Definition at line 278 of file epsfiltr.cpp.

00279 {
00280     // Start off with empty rectangle
00281     DocRect RangeBBox;
00282 
00283     // Do each range in turn
00284     RangeListItem *pItem = (RangeListItem *) GetHead();
00285 
00286     while (pItem != NULL)
00287     {
00288         // Do each node in turn
00289         if(pItem->IsLayer)
00290         {
00291             // layer based calcuations
00292 
00293             // see long note below
00294             RangeBBox = RangeBBox.Union(pItem->TheLayer->GetBoundingRect(TRUE));
00295         }
00296         else
00297         {
00298             // range based calculations
00299             Node *pNode = pItem->TheRange.FindFirst();
00300 
00301             while (pNode != NULL)
00302             {
00303                 // Does this node have a bounding rectangle?
00304                 if (pNode->IsBounded())
00305                 {
00306                     // Yes - add it to our union
00307                     NodeRenderableBounded *pNodeBounded = (NodeRenderableBounded *) pNode;
00308 
00309                     // Pass in TRUE so that we don't do a 'proper' attribute scan for the
00310                     // bounding box - we only need an approximate bounding rectangle
00311                     // for centering it anyway.
00312                     // NB. this results in inaccurate bounding boxes in the tree, but when
00313                     //     we call this we're about to transform them anyway, so they'll
00314                     //     be updated correctly afterwards.
00315                     RangeBBox = RangeBBox.Union(pNodeBounded->GetBoundingRect(TRUE));
00316                 }
00317                 else
00318                 {
00319                     ENSURE(FALSE, "Found a non-renderable node in the import range");
00320                 }
00321 
00322                 // Try the next node.
00323                 pNode = pItem->TheRange.FindNext(pNode);
00324             }
00325         }
00326 
00327         // Try the next range
00328         pItem = (RangeListItem *) GetNext(pItem);
00329     }
00330 
00331     // Return the accumulated bounds
00332     return RangeBBox;
00333 }

void RangeList::Transform TransformBase Trans  ) 
 

Transforms all the nodes in all the ranges of this range list using the transform object given.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/09/94
Parameters:
Trans - the transform object to transform all the nodes by. [INPUTS]
See also:
Range::Transform; TransformBase

Definition at line 348 of file epsfiltr.cpp.

00349 {
00350     // Do each range in turn
00351     RangeListItem *pItem = (RangeListItem *) GetHead();
00352 
00353     while (pItem != NULL)
00354     {
00355         if(pItem->IsLayer)
00356         {
00357             pItem->TheLayer->Transform(Trans);
00358         }
00359         else
00360         {
00361             // Transform all nodes in this range
00362             Node *pNode = pItem->TheRange.FindFirst();
00363 
00364             while (pNode != NULL)
00365             {
00366                 // Is this node renderable?
00367                 if (pNode->IS_KIND_OF(NodeRenderable))
00368                 {
00369                     // Yes - transform it.
00370                     NodeRenderable *pNodeRenderable = (NodeRenderable *) pNode;
00371                     pNodeRenderable->Transform(Trans);
00372                 }
00373                 else
00374                 {
00375                     ENSURE(FALSE, "Found a non-renderable node in the import range");
00376                 }
00377 
00378                 // Try the next node.
00379                 pNode = pItem->TheRange.FindNext(pNode);
00380             }
00381         }
00382 
00383         // Try the next range
00384         pItem = (RangeListItem *) GetNext(pItem);
00385     }
00386 }


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:00:20 2007 for Camelot by  doxygen 1.4.4