OpBreakShapes Class Reference

This class will break compound paths into two or more simple paths. It will work when there are one or more compound paths selected. More...

#include <pathedit.h>

Inheritance diagram for OpBreakShapes:

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

Public Member Functions

 OpBreakShapes ()
 OpBreakShapes constructor.
void Do (OpDescriptor *)
 Performs the Break shapes operation.
virtual BOOL MayChangeNodeBounds () const

Static Public Member Functions

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

Detailed Description

This class will break compound paths into two or more simple paths. It will work when there are one or more compound paths selected.

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

Definition at line 563 of file pathedit.h.


Constructor & Destructor Documentation

OpBreakShapes::OpBreakShapes  ) 
 

OpBreakShapes constructor.

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

Errors: -

See also:
-

Definition at line 6337 of file pathedit.cpp.

06337                             : SelOperation()                                
06338 {                              
06339 }


Member Function Documentation

void OpBreakShapes::Do OpDescriptor  )  [virtual]
 

Performs the Break shapes operation.

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

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 6472 of file pathedit.cpp.

06473 {   
06474     // Obtain the current selections 
06475     SelRange* Selected = GetApplication()->FindSelection();
06476 
06477     NodePath* NewPath;
06478     // Now, because we're going to be doing mad things to the selection, we have to make a list
06479     // of all the selected nodes, so that adding nodes into the tree won't confuse us
06480 
06481     List* NodeList = Selected->MakeListOfNodes();
06482 
06483     NodeListItem* CurItem = (NodeListItem*)(NodeList->GetHead());
06484 
06485     if (!CurItem)
06486         goto FailAndDeleteList;
06487 
06488     while(CurItem)
06489     {
06490         if ((CurItem->pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodePath))   &&  // It's a NodePath  AND
06491             (((NodePath*)(CurItem->pNode))->InkPath.IsComplexPath())            &&  // It's complex     AND
06492             (CurItem->pNode->FindParentOfSelected() == NULL))                       // It's not selected inside
06493         {
06494             // get a pointer to the NodePath
06495             NodePath* ThisPath = (NodePath*)(CurItem->pNode);
06496             
06497             // Start at the very beginning (a very good place to start)
06498             INT32 SubPathIndex = 0;
06499             INT32 NumCoords = ThisPath->InkPath.GetNumCoords();
06500 
06501             while (SubPathIndex < NumCoords)
06502             {
06503                 // Create a new path, copy this subpath into it, and link it into the tree
06504                 // Create the path
06505                 NewPath = new NodePath;
06506                 if (!NewPath)
06507                 {
06508                     goto FailAndDeleteList;
06509                 }
06510                 
06511                 // Initialise the path
06512                 if (!NewPath->SetUpPath(24,12))
06513                 {
06514                     InformError(_R(IDS_OUT_OF_MEMORY), _R(IDS_OK));
06515                     goto FailAndDeleteListAndPath;
06516                 }
06517 
06518                 // Copy all attributes from the original shape to the new path
06519                 Node* pAttr = ThisPath->FindFirstChild();
06520                 while (pAttr != NULL)
06521                 {
06522                     if (pAttr->IsAnAttribute())
06523                     {
06524                         BOOL ok;
06525                         Node* pAttrCopy;
06526                         CALL_WITH_FAIL(pAttr->NodeCopy(&pAttrCopy), this, ok);
06527                         if (!ok) 
06528                         {
06529                             goto FailAndDeleteListAndPath;
06530                         }
06531                         pAttrCopy->AttachNode(NewPath, FIRSTCHILD);
06532                     }
06533                     pAttr = pAttr->FindNext();
06534                 }
06535 
06536                 // Set the filled bit if the original path has the filled bit set
06537                 if (ThisPath->InkPath.IsFilled)
06538                     NewPath->InkPath.IsFilled = TRUE;
06539                 
06540                 // Now copy the current subpath into this object
06541                 // Find the last element in the subpath
06542                 INT32 EndOfSubPath = SubPathIndex;
06543                 ThisPath->InkPath.FindEndOfSubPath(&EndOfSubPath);
06544                 // Skip to the next element (this will give us the number of elements)
06545                 ThisPath->InkPath.FindNext(&EndOfSubPath);
06546 
06547                 // Now EndOfSubPath either points at the start of the next subpath, or 
06548                 // the top of the path (i.e. the first free space).
06549 
06550                 // Now copy it
06551                 if (!(NewPath->InkPath.CopySectionFrom(ThisPath->InkPath, SubPathIndex, EndOfSubPath-SubPathIndex)))
06552                 {
06553                     InformError(_R(IDS_OUT_OF_MEMORY), _R(IDS_OK));
06554                     goto FailAndDeleteListAndPath;
06555                 }
06556                 
06557                 // Set the index to the start of the next subpath
06558                 SubPathIndex = EndOfSubPath;
06559 
06560                 // Now stick it in the tree
06561                 if (!DoInsertNewNode(NewPath, ThisPath, NEXT, TRUE))
06562                 {
06563                     goto FailAndDeleteListAndPath;
06564                 }
06565 
06566                 // And that's it - no need to do anything more, just loop to the next subpath
06567             }
06568 
06569             // Now we've broken up this object, let's hide it
06570             if (!DoHideNode(ThisPath, TRUE))
06571                 goto FailAndDeleteList;
06572 
06573         }
06574         CurItem = (NodeListItem*)(NodeList->GetNext(CurItem));
06575     }
06576     
06577     End();
06578 
06579     // delete the nodelist (and all the list items)
06580     while (!NodeList->IsEmpty())
06581         delete (NodeListItem*)(NodeList->RemoveHead());
06582     delete NodeList;
06583 
06584     return;
06585 
06586 FailAndDeleteListAndPath:
06587 
06588     NewPath->CascadeDelete();
06589     delete NewPath;
06590 
06591 FailAndDeleteList:
06592     while (!NodeList->IsEmpty())
06593         delete (NodeListItem*)(NodeList->RemoveHead());
06594     delete NodeList;
06595     FailAndExecute();
06596     End();
06597     return;
06598 }

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

For finding the OpBreakShapes's state.

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

Errors: -

See also:
-

Definition at line 6390 of file pathedit.cpp.

06391 {
06392     OpState OpSt;
06393     String_256 DisableReason; 
06394 
06395     // Ensure that a document exists
06396     if (Document::GetSelected() == NULL)
06397     {
06398         // There is no slected document
06399         OpSt.Greyed = TRUE;
06400         // Load reason why operation is disabled
06401         DisableReason = String_256(_R(IDS_NO_DOC));
06402         *UIDescription = DisableReason;      
06403         return OpSt;                                 
06404     }
06405 
06406 
06407     OpSt.Greyed = FALSE;
06408 
06409     // Look at the current selection
06410     SelRange* Selected = GetApplication()->FindSelection();
06411     Node* pNode = Selected->FindFirst();
06412 
06413     // Go through the selection until we find a complex path that's not selected inside
06414     BOOL FoundComplex = FALSE;
06415     BOOL SelectedInside = FALSE;    // TRUE only if the last selected complex path is selected inside
06416     while (pNode)
06417     {
06418         if (pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodePath))
06419         {
06420             // Have we found a complex path?
06421             FoundComplex    = (((NodePath*)pNode)->InkPath.IsComplexPath());
06422 
06423             // Set SelectedInside to TRUE if we find a complex path AND it's selected inside.  FALSE otherwise
06424             // This is important, otherwise the greying out code below won't work correctly.
06425             SelectedInside  = (FoundComplex && (pNode->FindParentOfSelected() != NULL));
06426 
06427             // If we find a complex path that's not selected inside another node, so let op be doable
06428             if (FoundComplex && !SelectedInside)
06429                 break;
06430         }
06431         pNode = Selected->FindNext(pNode);
06432     }
06433     
06434     // The operation is disabled if there are no complex paths selected
06435 
06436     if (!FoundComplex)
06437     {
06438         OpSt.Greyed = TRUE;
06439         DisableReason = String_256(_R(IDS_BREAK_NEEDS_COMPLEX));
06440         *UIDescription = DisableReason;
06441     }
06442     else
06443     {
06444         // Greyed out if paths are selected inside.
06445         if (SelectedInside)
06446         {
06447             OpSt.Greyed = TRUE;
06448             DisableReason = String_256(_R(IDS_GREY_WHEN_SELECT_INSIDE));
06449             *UIDescription = DisableReason;
06450         }
06451     }
06452     
06453     return(OpSt);   
06454 }

BOOL OpBreakShapes::Init void   )  [static]
 

OpBreakShapes initialiser method.

Author:
Jim_Lynn (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/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 6359 of file pathedit.cpp.

06360 {
06361 
06362     BTNOP( BREAKSHAPEOP, OpBreakShapes, ARRANGE)
06363     return TRUE;
06364 //  return (RegisterOpDescriptor(0,
06365  //                         _R(IDS_JOINSHAPEOP),
06366 //                          CC_RUNTIME_CLASS(OpJoinShapes),
06367  //                         OPTOKEN_NODEPATH,
06368  //                         OpJoinShapes::GetState,
06369  //                         0,  /* help ID */
06370  //                         _R(IDBBL_NODEPATHOP),
06371  //                         0   /* bitmap ID */)); 
06372 
06373 }               

virtual BOOL OpBreakShapes::MayChangeNodeBounds  )  const [inline, virtual]
 

Reimplemented from SelOperation.

Definition at line 575 of file pathedit.h.

00575 { return FALSE; }


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