OpJoinShapes Class Reference

This class takes two or more selected paths and combines them into one path. More...

#include <pathedit.h>

Inheritance diagram for OpJoinShapes:

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

Public Member Functions

 OpJoinShapes ()
 OpJoinShapes constructor.
void Do (OpDescriptor *)
 Performs the Join shapes operation.

Static Public Member Functions

static BOOL Init ()
 OpJoinShapes initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding the OpJoinShapes's state.

Detailed Description

This class takes two or more selected paths and combines them into one path.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
See also:
-

Definition at line 537 of file pathedit.h.


Constructor & Destructor Documentation

OpJoinShapes::OpJoinShapes  ) 
 

OpJoinShapes constructor.

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

Errors: -

See also:
-

Definition at line 6015 of file pathedit.cpp.

06015                           : SelOperation()                              
06016 {                              
06017 }


Member Function Documentation

void OpJoinShapes::Do OpDescriptor  )  [virtual]
 

Performs the Join shapes operation.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com> (rewritten by Markn 12/1/96)
Date:
20/7/94
Parameters:
OpDescriptor (unused) [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 6141 of file pathedit.cpp.

06142 {   
06143     BOOL ok = TRUE;
06144     
06145     // remember the selection before the operation
06146     if (ok)
06147         ok = DoStartSelOp(FALSE,FALSE);
06148 
06149     // Get the current selection
06150     SelRange* Selected = GetApplication()->FindSelection();
06151 
06152     // Create a new NodePath and insert it into the tree
06153     Node* pNode = Selected->FindFirst();
06154     NodePath* pJoinedPath = NULL;
06155     if (ok) (pJoinedPath = new NodePath);
06156     if (ok) ok = (pJoinedPath != NULL);
06157     if (ok) ok = pJoinedPath->SetUpPath();
06158     if (ok) ok = DoInsertNewNode(pJoinedPath,pNode,PREV,FALSE,FALSE,FALSE,FALSE);
06159 
06160     // JoinBecomeA will receive all the paths created by the selection and merge them into pJoinedPath
06161     JoinShapesBecomeA JoinBecomeA(pJoinedPath);
06162 
06163     // Now go through the selection, copying path data from selected paths into the new one
06164     pNode = Selected->FindFirst();
06165     while (ok && (pNode != NULL))
06166     {
06167         // Find the next node in the selection now, because this one might get hidden
06168         Node* pNextNode = Selected->FindNext(pNode);
06169 
06170         // Ask each node that can create a NodePath to do so via DoBecomeA.
06171         if (pNode != NULL && pNode->IsAnObject() && pNode->CanBecomeA(&JoinBecomeA))
06172             ok = ((NodeRenderableInk*)pNode)->DoBecomeA(&JoinBecomeA);
06173 
06174         // Next node
06175         pNode = pNextNode;
06176     }
06177 
06178     // Apply the attributes of the last node to generate a NodePath
06179     if (ok)
06180     {
06181         CCAttrMap* pAttrMap = JoinBecomeA.GetLastAttrMap();
06182         if (pAttrMap != NULL)
06183             pJoinedPath->ApplyAttributes(pAttrMap,TRUE);
06184     }
06185 
06186     // Hide all the selected nodes
06187     pNode = Selected->FindFirst();
06188     while (ok && pNode != NULL)
06189     {
06190         Node* pNextNode = Selected->FindNext(pNode);
06191 
06192         if (pNode != NULL)
06193             ok = DoHideNode(pNode,TRUE);
06194 
06195         // Next node
06196         pNode = pNextNode;
06197     }
06198 
06199     // Select the node, ensure that it's bounds are recalculated, and redraw it
06200     if (ok) pJoinedPath->Select(FALSE);
06201     if (ok) pJoinedPath->InvalidateBoundingRect();
06202     if (ok) ok = DoInvalidateNodeRegion(pJoinedPath,TRUE);
06203 
06204     // Inform any error that may occur
06205     if (!ok)
06206     {
06207         InformError();
06208         FailAndExecute();
06209     }
06210 
06211     // Tell the application to refresh the selection
06212     GetApplication()->UpdateSelection();
06213         
06214     End();
06215 }           

OpState OpJoinShapes::GetState String_256 UIDescription,
OpDescriptor
[static]
 

For finding the OpJoinShapes's state.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
The state of the OpJoinShapes

Errors: -

See also:
-

Definition at line 6068 of file pathedit.cpp.

06069 {
06070     OpState OpSt;
06071     String_256 DisableReason; 
06072 
06073     // Ensure that a document exists
06074     if (Document::GetSelected() == NULL)
06075     {
06076         // There is no selected document
06077         OpSt.Greyed = TRUE;
06078 
06079         // Load reason why operation is disabled
06080         DisableReason = String_256(_R(IDS_NO_DOC));
06081         *UIDescription = DisableReason;      
06082         return OpSt;                                 
06083     }
06084 
06085     OpSt.Greyed = FALSE;
06086 
06087     // Look at the current selection
06088     SelRange* Selected = GetApplication()->FindSelection();
06089     Node* pNode = Selected->FindFirst();
06090     BOOL SelectedInside = FALSE;
06091     BecomeA MyBecomeA(BECOMEA_TEST, CC_RUNTIME_CLASS(NodePath));
06092     MyBecomeA.ResetCount();
06093     
06094     while (pNode != NULL)
06095     {
06096         if (pNode->CanBecomeA(&MyBecomeA))
06097         {
06098             if (pNode->FindParentOfSelected() != NULL)
06099                 SelectedInside = TRUE;
06100         }
06101         pNode = Selected->FindNext(pNode);
06102     }
06103     
06104     // The operation is disabled if there are less than one path to join
06105     if (MyBecomeA.GetCount() < 2)
06106     {
06107         OpSt.Greyed = TRUE;
06108         DisableReason = String_256(_R(IDS_JOIN_NEEDS_TWO_PATHS));
06109         *UIDescription = DisableReason;
06110     }
06111     else
06112     {
06113         // Greyed out if paths are selected inside.
06114         if (SelectedInside)
06115         {
06116             OpSt.Greyed = TRUE;
06117             DisableReason = String_256(_R(IDS_GREY_WHEN_SELECT_INSIDE));
06118             *UIDescription = DisableReason;
06119         }
06120     }
06121     
06122     return(OpSt);   
06123 }

BOOL OpJoinShapes::Init void   )  [static]
 

OpJoinShapes initialiser method.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/7/94
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if the operation could be successfully initialised FALSE if no more memory could be allocated

Errors: ERROR will be called if there was insufficient memory to allocate the operation.

See also:
-

Reimplemented from SimpleCCObject.

Definition at line 6037 of file pathedit.cpp.

06038 {
06039 
06040     BTNOP( JOINSHAPEOP, OpJoinShapes, ARRANGE)
06041     return TRUE;
06042 //  return (RegisterOpDescriptor(0,
06043  //                         _R(IDS_JOINSHAPEOP),
06044 //                          CC_RUNTIME_CLASS(OpJoinShapes),
06045  //                         OPTOKEN_NODEPATH,
06046  //                         OpJoinShapes::GetState,
06047  //                         0,  /* help ID */
06048  //                         _R(IDBBL_NODEPATHOP),
06049  //                         0   /* bitmap ID */)); 
06050 
06051 }               


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