NodeRect Class Reference

A Node rect represents a rectangle object in the tree. It is derived from NodeSimple Shape that contains most of the functionality it needs. Simple Shapes are a group of nodes that are based around a parallelogram. The shape is fitted into a parallelogram so that it can be transformed while keeping its own identity (ie, it does not have to be turned into a NodePath). More...

#include <noderect.h>

Inheritance diagram for NodeRect:

NodeSimpleShape NodeRenderableInk NodeRenderableBounded NodeRenderable Node CCObject SimpleCCObject NodeBitmap NodeAnimatingBitmap List of all members.

Public Member Functions

 NodeRect ()
 This constructor creates a NodeRect linked to no other with all status flags false and an uninitialized bounding rectangle.
 NodeRect (Node *ContextNode, AttachNodeDirection Direction, BOOL Locked=FALSE, BOOL Mangled=FALSE, BOOL Marked=FALSE, BOOL Selected=FALSE)
 This constructor initialises the nodes flags and links it to ContextNode in the direction specified by Direction. All neccesary tree links are updated.
virtual NodeSimpleCopy ()
 Makes a copy of all the data in the node.
virtual String Describe (BOOL Plural, BOOL Verbose)
 To return a description of the NodeRect object in either the singular or the plural. This method is called by the DescribeRange method. The description will always begin with a lower case letter.
void PreExportRender (RenderRegion *pRegion)
 Output data required to mark this object as a rectangle as opposed to an arbitrary path.
virtual void CreateShape (DocRect NewRect)
 Creates a rectangle using a path.
virtual void UpdateShape ()
 Updates rectangle node to fit the current parallelogram.
virtual UINT32 GetNodeSize () const
 For finding the size of the node.
virtual BOOL SnapToCoords (DocCoord *pDocCoord)
 Snaps the point magnetically to the magnetic coords for a rectangle. These are :- The Centre, The Corners, and the midpoints of its edges.
virtual void HandleBlobDrag (DocCoord &, Spread *, INT32)
 When a drag is started on one of the paths blobs this is called. It tries to fire up an operation that will perform a drag of all the selected points, including all the EORing of the relavent parts of the curve. If it fails it will inform the user and not bother.

Private Member Functions

 CC_DECLARE_DYNCREATE (NodeRect)

Detailed Description

A Node rect represents a rectangle object in the tree. It is derived from NodeSimple Shape that contains most of the functionality it needs. Simple Shapes are a group of nodes that are based around a parallelogram. The shape is fitted into a parallelogram so that it can be transformed while keeping its own identity (ie, it does not have to be turned into a NodePath).

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>, Changed by Rik
Date:
22/9/93

Definition at line 122 of file noderect.h.


Constructor & Destructor Documentation

NodeRect::NodeRect  ) 
 

This constructor creates a NodeRect linked to no other with all status flags false and an uninitialized bounding rectangle.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/9/93
Note: SetUpPath() must be called before the NodeRect is in a state in which it can be used.

See also:
SetUpPath

Definition at line 200 of file noderect.cpp.

00200                   : NodeSimpleShape()
00201 {
00202 }

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

This constructor initialises the nodes flags and links it to ContextNode in the direction specified by Direction. All neccesary tree links are updated.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/9/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

BoundingRect: Bounding rectangle

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 ?

Note: SetUpPath() must be called before the NodeRect is in a state in which it can be used.

See also:
SetUpPath
Returns:
Errors: An assertion error will occur if ContextNode is NULL

Definition at line 170 of file noderect.cpp.

00176                :NodeSimpleShape(ContextNode, Direction, Locked, Mangled, Marked, Selected )  
00177 {                         
00178 }                        


Member Function Documentation

NodeRect::CC_DECLARE_DYNCREATE NodeRect   )  [private]
 

void NodeRect::CreateShape DocRect  NewRect  )  [virtual]
 

Creates a rectangle using a path.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>, Changed by Rik
Date:
22/9/93
Parameters:
DocRect - representing the rectangle to be created. [INPUTS]

Reimplemented from NodeSimpleShape.

Definition at line 293 of file noderect.cpp.

00294 {
00295     // Copy the rectangle into the parallelogram
00296     Parallel[0] = DocCoord(NewRect.lo.x, NewRect.hi.y);
00297     Parallel[1] = DocCoord(NewRect.hi.x, NewRect.hi.y);
00298     Parallel[2] = DocCoord(NewRect.hi.x, NewRect.lo.y);
00299     Parallel[3] = DocCoord(NewRect.lo.x, NewRect.lo.y);
00300 
00301     // build a path
00302     InkPath.FindStartOfPath();
00303 
00304     // Start at bottom left corner
00305     InkPath.InsertMoveTo(Parallel[0]);
00306     InkPath.InsertLineTo(Parallel[1]);
00307     InkPath.InsertLineTo(Parallel[2]);
00308     InkPath.InsertLineTo(Parallel[3]);
00309     InkPath.InsertLineTo(Parallel[0]);
00310 
00311     // Close the path properly
00312     InkPath.CloseSubPath();
00313 }

String NodeRect::Describe BOOL  Plural,
BOOL  Verbose
[virtual]
 

To return a description of the NodeRect object in either the singular or the plural. This method is called by the DescribeRange method. The description will always begin with a lower case letter.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/6/93
Parameters:
Plural,: Flag indicating if the string description should be plural or [INPUTS] singular. Retuns: Description of the object
Returns:
Errors: A resource exception will be thrown if a problem occurs when loading the string resource.

Reimplemented from Node.

Reimplemented in NodeAnimatingBitmap, and NodeBitmap.

Definition at line 247 of file noderect.cpp.

00248 {     
00249     if (Plural)
00250         return(String(_R(IDS_RECTANGLE_DESCRP)));  
00251     else
00252         return(String(_R(IDS_RECTANGLE_DESCRS))); 
00253 }; 

UINT32 NodeRect::GetNodeSize  )  const [virtual]
 

For finding the size of the node.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
6/10/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The size of the node in bytes
See also:
Node::GetSubtreeSize

Reimplemented from NodeSimpleShape.

Reimplemented in NodeAnimatingBitmap, and NodeBitmap.

Definition at line 395 of file noderect.cpp.

00396 {     
00397     return (sizeof(NodeRect)); 
00398 }  

void NodeRect::HandleBlobDrag DocCoord PointerPos,
Spread pSpread,
INT32  FixedCorner
[virtual]
 

When a drag is started on one of the paths blobs this is called. It tries to fire up an operation that will perform a drag of all the selected points, including all the EORing of the relavent parts of the curve. If it fails it will inform the user and not bother.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/11/93
Parameters:
PointerPos - The position the mouse pointer clicked [INPUTS] pSpread - the spread that the click was on FixedCorner - The corner of the parallelogram that will stay fixed during the drag

Reimplemented from NodeSimpleShape.

Definition at line 359 of file noderect.cpp.

00360 {
00361 #if !defined(EXCLUDE_FROM_RALPH)
00362     OpEditRectangle* pOpRect = new OpEditRectangle;
00363     if (pOpRect == NULL)
00364     {
00365         // Failed to get the memory to do the job
00366         TRACEUSER( "Rik", _T("The Node Rect Edit Operation failed to start\n") );
00367 
00368         // Inform the person doing the clicking that life is not looking so good
00369         InformError();
00370     }
00371     else
00372     {
00373         // Start the drag operation and pass in the Anchor Point to the operation
00374         pOpRect->DoDrag(PointerPos, pSpread, this, FixedCorner);
00375     }
00376 #endif
00377 }

void NodeRect::PreExportRender RenderRegion pRegion  )  [virtual]
 

Output data required to mark this object as a rectangle as opposed to an arbitrary path.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/08/94
Parameters:
pRegion - the render region we are exporting to. [INPUTS]

Reimplemented from Node.

Reimplemented in NodeBitmap.

Definition at line 268 of file noderect.cpp.

00269 {
00270 #ifdef DO_EXPORT
00271     if (pRegion->IsKindOf(CC_RUNTIME_CLASS(ArtWorksEPSRenderRegion)))
00272     {
00273         // Output "ArtWorks rectangle" token
00274         EPSExportDC *pDC = (EPSExportDC *) pRegion->GetRenderDC();
00275         pDC->OutputToken(_T("ar"));
00276         pDC->OutputNewLine();
00277     }
00278 #endif
00279 }

Node * NodeRect::SimpleCopy void   )  [virtual]
 

Makes a copy of all the data in the node.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/5/93
Returns:
Pointer to a Node

Reimplemented from NodeSimpleShape.

Reimplemented in NodeAnimatingBitmap, and NodeBitmap.

Definition at line 217 of file noderect.cpp.

00218 {
00219     // Make a new NodeSimpleShape and then copy things into it
00220     NodeRect* NodeCopy = new NodeRect();
00221     if (NodeCopy)
00222         CopyNodeContents(NodeCopy);
00223     
00224     return NodeCopy;
00225 }            

BOOL NodeRect::SnapToCoords DocCoord pDocCoord  )  [virtual]
 

Snaps the point magnetically to the magnetic coords for a rectangle. These are :- The Centre, The Corners, and the midpoints of its edges.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/11/94
Parameters:
pDocCoord - the coord to try and snap to [INPUTS]
pDocCoord - The snapped coord, if it was close enough to any of the magnetic [OUTPUTS] points for a rectangle.
Returns:
TRUE if it was snapped, FALSE if not

Reimplemented from NodeSimpleShape.

Definition at line 419 of file noderect.cpp.

00420 {
00421 #if !defined(EXCLUDE_FROM_RALPH)
00422     // First try and snap to all the places that the base class snaps for us
00423     BOOL IsSnapped = NodeSimpleShape::SnapToCoords(pDocCoord);
00424 
00425     // if it did not snap in the base class, try the extra points
00426     if (IsSnapped==FALSE)
00427     {
00428         // Try each of the corner of the rectangle
00429         for (INT32 i=0; i<4; i++)
00430         {
00431             if (IsMagneticallyClose(&Parallel[i], pDocCoord))
00432                 return TRUE;
00433         }
00434     }
00435 
00436     // send the result on
00437     return IsSnapped;
00438 #else
00439     return FALSE;
00440 #endif
00441 }

void NodeRect::UpdateShape  )  [virtual]
 

Updates rectangle node to fit the current parallelogram.

Author:
Mario_Shamtani (Xara Group Ltd) <camelotdev@xara.com>, Changed by Rik
Date:
22/9/93

Reimplemented from NodeSimpleShape.

Definition at line 325 of file noderect.cpp.

00326 {
00327     // make sure the path seems to have the correct number of coords in it
00328     ENSURE(InkPath.GetNumCoords()==5, "NodeRect::UpdateShape found its path corrupt" );
00329 
00330     // Get the array of coords in the path
00331     DocCoord* Coords = InkPath.GetCoordArray();
00332 
00333     // Update them to what we now have
00334     Coords[0] = Parallel[0];
00335     Coords[1] = Parallel[1];
00336     Coords[2] = Parallel[2];
00337     Coords[3] = Parallel[3];
00338     Coords[4] = Parallel[0];
00339 }


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