OpSmoothSelection Class Reference

This class will smooth paths between selected control point regions. It processes all selected objects within the current document. More...

#include <opsmooth.h>

Inheritance diagram for OpSmoothSelection:

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

Public Member Functions

 OpSmoothSelection ()
void GetOpName (String_256 *OpName)
 The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies.
void Do (OpDescriptor *)
 This operation will smooth all selected paths within the current document Before smoothing any complete path, the path is searched for selected points The action of the smooth given a number of selected points is as follows No sel points: Smooth the whole path One sel point: Smooth the whole path. Could smooth from the start of the path to this point but the user does not generally known which part is the start of the path. Two sel points: Smooth the section of path lying between these points. Even number: Smooth using inside/outside section processing. (a,b) (c,d) .... (y,z) etc are regions for smoothing Odd number: Smooth as for even number apart from last region (a,b) (c,d) ........ (f,g,h).

Static Public Member Functions

static BOOL Init ()
 OpDeletePoints initialiser method.
static OpState GetState (String_256 *, OpDescriptor *)
 For finding the OpSmoothSelection state.

Detailed Description

This class will smooth paths between selected control point regions. It processes all selected objects within the current document.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/10/94
See also:
-

Definition at line 123 of file opsmooth.h.


Constructor & Destructor Documentation

OpSmoothSelection::OpSmoothSelection  ) 
 


Member Function Documentation

void OpSmoothSelection::Do OpDescriptor  )  [virtual]
 

This operation will smooth all selected paths within the current document Before smoothing any complete path, the path is searched for selected points The action of the smooth given a number of selected points is as follows No sel points: Smooth the whole path One sel point: Smooth the whole path. Could smooth from the start of the path to this point but the user does not generally known which part is the start of the path. Two sel points: Smooth the section of path lying between these points. Even number: Smooth using inside/outside section processing. (a,b) (c,d) .... (y,z) etc are regions for smoothing Odd number: Smooth as for even number apart from last region (a,b) (c,d) ........ (f,g,h).

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/10/94
Parameters:
pointer to an OpDescriptor (unused) [INPUTS]
- [OUTPUTS]
Returns:
-

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

Reimplemented from Operation.

Definition at line 290 of file opsmooth.cpp.

00291 {
00292     // Obtain the current selections 
00293     SelRange* Selected = GetApplication()->FindSelection();
00294     NodePath* pSmoothNode;
00295 
00296     // Now, because we're going to be doing mad things to the selection, we have to make a list
00297     // of all the selected nodes, so that adding nodes into the tree won't confuse us
00298 
00299     List* NodeList = Selected->MakeListOfNodes();
00300     NodeListItem* CurItem = (NodeListItem*)(NodeList->GetHead());
00301 
00302     if (!CurItem)
00303         goto FailAndDeleteList;
00304 
00305     // remember the selection before the operation
00306     if (!DoStartSelOp(FALSE,FALSE))
00307         goto FailAndDeleteList;
00308 
00309     while (CurItem)
00310     {
00311         if (CurItem->pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodePath))
00312         {
00313             // get a pointer to the NodePath
00314             NodePath* pThisNode = (NodePath*)(CurItem->pNode);
00315 
00316             BOOL ok;
00317             Node* pnode;
00318 
00319             // Copy the nodepath and all its children, without placing the copy in the tree
00320             CALL_WITH_FAIL(pThisNode->NodeCopy(&pnode), this, ok);
00321             if (!ok) goto DeleteList;
00322             pSmoothNode = (NodePath*)pnode;
00323 
00324             // ok, smooth the nodepaths path data
00325             double error = SMOOTH_CONSTANT;
00326             CALL_WITH_FAIL(pSmoothNode->InkPath.SmoothRegions(error, FALSE, TRUE), this, ok);
00327             if (!ok) goto DeleteListAndPath;
00328 
00329             // update the smoothed paths bounding rectangle
00330             pSmoothNode->InvalidateBoundingRect();
00331             pSmoothNode->InkPath.ClearSubSelection();
00332 
00333             // Now stick the new path into the tree
00334             CALL_WITH_FAIL(DoInsertNewNode(pSmoothNode, pThisNode, NEXT, TRUE), this, ok);
00335             if (!ok) goto DeleteListAndPath;
00336             
00337             // Now we've formed a smoothed path, let's hide the original
00338             CALL_WITH_FAIL(DoHideNode(pThisNode,TRUE), this, ok);
00339             if (!ok) goto DeleteList;
00340 
00341         }
00342         CurItem = (NodeListItem*)(NodeList->GetNext(CurItem));
00343     }
00344 
00345     End();
00346 
00347     // delete the nodelist (and all the list items)
00348     while (!NodeList->IsEmpty())
00349         delete (NodeListItem*)(NodeList->RemoveHead());
00350     delete NodeList;
00351     return;
00352 
00353 
00354 FailAndDeleteList:
00355     while (!NodeList->IsEmpty())
00356         delete (NodeListItem*)(NodeList->RemoveHead());
00357     delete NodeList;
00358     FailAndExecute();
00359     End();
00360     return;
00361 
00362 DeleteListAndPath:
00363     pSmoothNode->CascadeDelete();
00364     delete pSmoothNode;
00365 DeleteList:
00366     while (!NodeList->IsEmpty())
00367         delete (NodeListItem*)(NodeList->RemoveHead());
00368     delete NodeList;
00369     End();
00370     return;
00371 
00372 }

void OpSmoothSelection::GetOpName String_256 OpName  )  [virtual]
 

The GetOpName fn is overridden so that we return back a description appropriate to the type of attribute that the operation applies.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
20/10/94
Parameters:
- [INPUTS]
The undo string for the operation [OUTPUTS]
Returns:

Errors: -

See also:
-

Reimplemented from Operation.

Definition at line 253 of file opsmooth.cpp.

00254 {
00255     *OpName = String_256(_R(IDS_UNDO_SMOOTHSELECTIONOP));
00256 }

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

For finding the OpSmoothSelection state.

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

Errors: -

See also:
-

Definition at line 195 of file opsmooth.cpp.

00196 {
00197     OpState OpSt;
00198     String_256 DisableReason; 
00199 
00200     OpSt.Greyed = FALSE;
00201     BOOL FoundSelected = FALSE;
00202 
00203     // Go through the selection until we find a selected point
00204 
00205     SelRange* Selected = GetApplication()->FindSelection();
00206     Node* pNode = Selected->FindFirst();
00207 
00208     while (pNode)
00209     {
00210         if (pNode->GetRuntimeClass() == CC_RUNTIME_CLASS(NodePath))
00211         {
00212             if (((NodePath*)pNode)->InkPath.NumSplinters() >0 )
00213             {
00214                 FoundSelected = TRUE;
00215                 break;
00216             }
00217 
00218         }
00219         pNode = Selected->FindNext(pNode);
00220     }
00221 
00222     // The operation is disabled if there are no complex paths selected
00223 
00224     if (!FoundSelected)
00225     {
00226         OpSt.Greyed = TRUE;
00227         DisableReason = String_256(_R(IDS_NEEDS_SELECTED_POINT));
00228         *UIDescription = DisableReason;
00229     }
00230 
00231     return(OpSt);   
00232 }

BOOL OpSmoothSelection::Init void   )  [static]
 

OpDeletePoints initialiser method.

Author:
Mike_Kenny (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/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 158 of file opsmooth.cpp.

00159 {
00160     return (RegisterOpDescriptor(0,                                 // tool ID
00161                                 _R(IDS_SMOOTHSELECTIONOP),              // string resource ID
00162                                 CC_RUNTIME_CLASS(OpSmoothSelection),// runtime class for Op
00163                                 OPTOKEN_SMOOTHSELECTION,            // Ptr to token string
00164                                 OpSmoothSelection::GetState,        // GetState function
00165                                 0,                                  // help ID
00166                                 _R(IDBBL_SMOOTHSELECTIONOP),            // bubble help ID
00167                                 _R(IDD_BARCONTROLSTORE),                // resource ID
00168                                 _R(IDC_BTN_SMOOTHSELECTIONOP),          // control ID
00169                                 SYSTEMBAR_EDIT,                     // Group bar ID
00170                                 TRUE,                               // Receive messages
00171                                 FALSE,                              // Smart
00172                                 FALSE,                              // Clean
00173                                 0,                                  // One open Instance ID
00174                                 (GREY_WHEN_NO_CURRENT_DOC | GREY_WHEN_NO_SELECTION)
00175                                 )); 
00176 
00177 }               


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