OpPasteMouldShape Class Reference

An undoable operation to paste the contents of the clipboard as a mould shape. More...

#include <moldtool.h>

Inheritance diagram for OpPasteMouldShape:

OpMouldLibSel SelOperation UndoableOperation Operation MessageHandler ListItem CCObject SimpleCCObject OpPasteEnvelope OpPastePerspective List of all members.

Public Member Functions

 OpPasteMouldShape ()
 Constructor for paste mould shape operation.

Protected Member Functions

void Do (MouldSpace mSpace)
 Take the contents of the clipboard and try to use whatever shape exists there as a mould shape. The mould space type is passed to this function as a parameter. The function will find the first renderable object on the clipboard, try to make shapes of it and use the first shape returned as the mould space object.

Static Protected Member Functions

static BOOL FindPasteObject (Node **pReturnNode)
 This function scans for objects on the clipboard. It tries to find the first object which Is a NodeRenderableInk Can become a nodepath If there is such an object the function will return true, and set the return pointer to point at the object if the return pointer exists ie is a none null receptor.

Detailed Description

An undoable operation to paste the contents of the clipboard as a mould shape.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/01/95
See also:

Definition at line 394 of file moldtool.h.


Constructor & Destructor Documentation

OpPasteMouldShape::OpPasteMouldShape  ) 
 

Constructor for paste mould shape operation.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/01/95
See also:
-

Definition at line 1981 of file moldtool.cpp.

01982 {
01983     // Dummy constructor
01984 }


Member Function Documentation

void OpPasteMouldShape::Do MouldSpace  mSpace  )  [protected]
 

Take the contents of the clipboard and try to use whatever shape exists there as a mould shape. The mould space type is passed to this function as a parameter. The function will find the first renderable object on the clipboard, try to make shapes of it and use the first shape returned as the mould space object.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/01/95
Parameters:
mSpace = the mould space to paste as [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: failandexecute will be called if the operation fails in some way, most likely when no memory is available.

Definition at line 2053 of file moldtool.cpp.

02054 {
02055     BeginSlowJob();
02056 
02057     Node* pPasteNode;
02058     BOOL Constrain=KeyPress::IsConstrainPressed();
02059 
02060     // Obtain the current selections 
02061     SelRange* Selected = GetApplication()->FindSelection();
02062     if (!Selected)
02063     {
02064         FailAndExecute(); End(); return;
02065     }
02066 
02067     // is there a suitable object on the clipboard?
02068     if (!FindPasteObject(&pPasteNode))
02069     {
02070         FailAndExecute(); End(); return;
02071     }
02072 
02073     // HERE
02074 
02075     // If so lets force the object to become a nodepath
02076     // Do this none undoably because we are doing things on the clipboard.
02077     // If we DoBecomeA passback on a perspectivised filled object, it hides
02078     // the original?
02079     MouldBecomeA ParamBecomeA(  BECOMEA_PASSBACK, 
02080                                 CC_RUNTIME_CLASS(NodePath),
02081                                 NULL);
02082 
02083     // Get pNode to generate its paths for us
02084     BOOL ok = pPasteNode->DoBecomeA(&ParamBecomeA);
02085     // whip the resulting mould path out of the do becomea param class
02086     NodePath* pNodePath = ParamBecomeA.GetMouldPath();
02087     if ((!ok) || pNodePath==NULL)
02088     {
02089         FailAndExecute(); End(); return;
02090     }
02091 
02092     // remember the selection before the operation
02093     if (!DoStartSelOp(TRUE,TRUE))
02094     {
02095         FailAndExecute(); End(); return;
02096     }
02097 
02098     ObjChangeFlags cFlags;
02099     cFlags.DeleteNode  = TRUE;
02100     ObjChangeParam ObjChange(OBJCHANGE_STARTING,cFlags,NULL,this);
02101 
02102     if (!Selected->AllowOp(&ObjChange))
02103     {
02104         ERROR3("AllowOp() returned FALSE, i.e. op should have been greyed out");
02105         FailAndExecute(); End(); return;
02106     }
02107 
02108     // Trash the selection bounds
02109     Range Rnge = (*Selected);
02110     if (!DoInvalidateNodesRegions(Rnge,TRUE,TRUE))
02111     {
02112         FailAndExecute(); End(); return;
02113     }
02114 
02115     // Calculate the destination paste position
02116     DocRect Bounds  = Selected->GetBoundingRect();
02117     DocRect sBounds = pNodePath->GetBoundingRect();
02118 
02119     Node* pNode = Selected->FindFirst();
02120     if (pNode==NULL)
02121     {
02122         FailAndExecute(); End(); return;
02123     }
02124     
02125     if (!Constrain)
02126     {
02127         // If we're not constraining, then we might have to force constrain
02128         // on to ensure the object pastes within the bounds of the spread.
02129         // We'll try to expand the pasteboard, and if that fails, we'll
02130         // turn constrain on
02131         
02132         // find the spread of the destination selected node (fix to Jason bug)
02133         Spread *pSpread = pNode->FindParentSpread();
02134         if (pSpread == NULL || !pSpread->ExpandPasteboardToInclude(sBounds))
02135             Constrain=TRUE;
02136     }
02137 
02138     if (Constrain)
02139     {
02140         // if 'control' constrain is pressed then paste the mould
02141         // shape centred over the selection otherwise leave it where
02142         // it is.
02143         INT32 tx = (Bounds.lo.x+Bounds.hi.x)/2 - (sBounds.lo.x+sBounds.hi.x)/2;
02144         INT32 ty = (Bounds.lo.y+Bounds.hi.y)/2 - (sBounds.lo.y+sBounds.hi.y)/2;
02145         Trans2DMatrix trans(tx,ty);
02146         pNodePath->Transform(trans);
02147     }
02148 
02149     // Grab the ink path from its node
02150     Path* pShape = &(pNodePath->InkPath);
02151 
02152     // using this list create or replace the mould bits
02153     ok = DoCreateOrReplaceMould(Selected, pShape, mSpace, TRUE, FALSE);
02154     if (!ok)
02155         FailAndExecute();
02156 
02157     // Update all the changed nodes, i.e. tell all the parents of the children that have been effected
02158     ObjChange.Define (OBJCHANGE_FINISHED,cFlags,NULL,this);
02159     UpdateChangedNodes(&ObjChange);
02160 
02161     End();
02162 }

BOOL OpPasteMouldShape::FindPasteObject Node **  pReturnNode  )  [static, protected]
 

This function scans for objects on the clipboard. It tries to find the first object which Is a NodeRenderableInk Can become a nodepath If there is such an object the function will return true, and set the return pointer to point at the object if the return pointer exists ie is a none null receptor.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
09/02/95
Parameters:
pReturnNode,a pointer to a pointer, which can be null if no return [INPUTS] node is required.
pReturnNode holds a pointer to the node to be pasted, if a suitable node [OUTPUTS] has been found and the pointer pointer is none null on entry
Returns:
TRUE if a suitable paste object has been found FALSE if none

Definition at line 2008 of file moldtool.cpp.

02009 {
02010     BOOL found=FALSE;
02011 
02012     // find the first object
02013     Node* pNode = InternalClipboard::GetInsertionLayer()->FindFirstChild();
02014     while (pNode && !found)
02015     {
02016         // ok lets check what we've got here
02017         BecomeA TestBecomeAPath(BECOMEA_TEST, CC_RUNTIME_CLASS(NodePath));
02018         if ((pNode->IsKindOf(CC_RUNTIME_CLASS(NodeRenderableInk))) &&
02019             (pNode->CanBecomeA(&TestBecomeAPath))
02020            )
02021             found=TRUE;
02022         else
02023             pNode=pNode->FindNext();
02024     }
02025 
02026     if (found && pReturnNode)
02027         *pReturnNode=pNode;
02028 
02029     return found;
02030 }


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