#include <pathops.h>
Inheritance diagram for OpMovePathPoint:
Public Member Functions | |
OpMovePathPoint () | |
OpMovePathPoint constructor - does nothing itself. | |
void | DoWithParam (OpDescriptor *, OpParam *) |
An operation to position elements in a path (in an undoable kind of way). | |
Static Public Member Functions | |
static BOOL | Init () |
OpMovePathPoint initialiser method. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
For finding the OpCyclePathSelectionFoward's state. | |
Private Member Functions | |
BOOL | ClearSmoothAndRotate (NodePath *pPath, INT32 PathIndex) |
This function calls DoAlterPathElement to clear the Smooth and Rotate flags from the specified path endpoint. |
Definition at line 245 of file pathops.h.
|
OpMovePathPoint constructor - does nothing itself.
Definition at line 711 of file pathops.cpp. 00711 : TransOperation() 00712 { 00713 }
|
|
This function calls DoAlterPathElement to clear the Smooth and Rotate flags from the specified path endpoint.
Definition at line 947 of file pathops.cpp. 00948 { 00949 PathFlags* Flags = pPath->InkPath.GetFlagArray(); 00950 PathVerb* Verbs = pPath->InkPath.GetVerbArray(); 00951 DocCoord* Coords= pPath->InkPath.GetCoordArray(); 00952 00953 PathFlags tFlags = Flags[PathIndex]; 00954 tFlags.IsSmooth = FALSE; 00955 tFlags.IsRotate = FALSE; 00956 return DoAlterPathElement(pPath, PathIndex, Coords[PathIndex], tFlags, Verbs[PathIndex]); 00957 }
|
|
An operation to position elements in a path (in an undoable kind of way).
Reimplemented from TransOperation. Definition at line 777 of file pathops.cpp. 00778 { 00779 // Cast parameter block to our type 00780 MovePointsParams* MyParams = (MovePointsParams*)Params; 00781 00782 ERROR3IF(MyParams == NULL, "Parameter block pointer was NULL"); 00783 ERROR3IF(MyParams->ChangesCount == 0, "No elements to alter!"); 00784 ERROR3IF(MyParams->PathChanges == NULL, "No changes data supplied (NULL pointer passed)"); 00785 ERROR3IF(MyParams->PathToEdit == NULL, "No changes path supplied (NULL pointer passed)"); 00786 00787 // Do the above tests again for the retail build 00788 if ( (MyParams == NULL) || (MyParams->ChangesCount == 0) || (MyParams->PathChanges == NULL) 00789 || (MyParams->PathToEdit == NULL) ) 00790 { 00791 End(); 00792 return; 00793 } 00794 00795 // Get pointers to the path data. 00796 PathFlags* Flags = MyParams->PathToEdit->InkPath.GetFlagArray(); 00797 PathVerb* Verbs = MyParams->PathToEdit->InkPath.GetVerbArray(); 00798 DocCoord* Coords= MyParams->PathToEdit->InkPath.GetCoordArray(); 00799 INT32 NumElements = MyParams->PathToEdit->InkPath.GetNumCoords(); 00800 BOOL NotFailed = TRUE; 00801 00802 // Tell the operation system to start. 00803 if (!DoStartTransOp(FALSE,MyParams->PathToEdit)) 00804 { 00805 FailAndExecute(); 00806 End(); 00807 return; 00808 } 00809 00810 for (INT32 Loop = 0; (Loop < MyParams->ChangesCount) && NotFailed; Loop++) 00811 { 00812 // Get the index of the point to edit 00813 INT32 Index = MyParams->PathChanges[Loop].Element; 00814 DocCoord NewCoord = MyParams->PathChanges[Loop].Coordinate; 00815 00816 ERROR3IF(((Index >= NumElements) || (Index < 0)), "Invalid index into path (either -ve or off end of path)"); 00817 if ((Index >= NumElements) || (Index < 0)) 00818 { 00819 FailAndExecute(); 00820 End(); 00821 return; 00822 } 00823 00824 // Find the start and end of the subpath containing index 00825 INT32 EndOfSubPathIndex = Index; 00826 MyParams->PathToEdit->InkPath.FindEndElOfSubPath(&EndOfSubPathIndex); 00827 INT32 StartOfSubPathIndex = EndOfSubPathIndex; 00828 while ((Verbs[StartOfSubPathIndex] != PT_MOVETO) && (StartOfSubPathIndex > 0)) 00829 StartOfSubPathIndex--; 00830 BOOL IsSubPathClosed = (Verbs[EndOfSubPathIndex] & PT_CLOSEFIGURE); 00831 00832 // Move the point to the required coordinate 00833 NotFailed = DoAlterPathElement(MyParams->PathToEdit, Index, NewCoord, Flags[Index], Verbs[Index]); 00834 00835 // If we have just moved one endpoint of a closed path we will have to move the 00836 // other point too! 00837 if ( NotFailed && IsSubPathClosed ) 00838 { 00839 if (Index == EndOfSubPathIndex) 00840 { 00841 NotFailed = DoAlterPathElement(MyParams->PathToEdit, StartOfSubPathIndex, NewCoord, 00842 Flags[StartOfSubPathIndex], Verbs[StartOfSubPathIndex]); 00843 } 00844 if (Index == StartOfSubPathIndex) 00845 { 00846 NotFailed = DoAlterPathElement(MyParams->PathToEdit, EndOfSubPathIndex, NewCoord, 00847 Flags[EndOfSubPathIndex], Verbs[EndOfSubPathIndex]); 00848 } 00849 } 00850 00851 // Now if we have just moved a Bezier control point then we need to clear the 00852 // smooth and rotate flags from the associated endpoint. We are lucky in that a 00853 // control point's endpoint is at either +1 or -1 elements away from the control point. 00854 if (NotFailed && ( (Verbs[Index] == PT_BEZIERTO) && !Flags[Index].IsEndPoint) ) 00855 { 00856 INT32 BezEndpoint = -1; 00857 00858 if ((Verbs[Index+1] & ~PT_CLOSEFIGURE) == PT_BEZIERTO) 00859 BezEndpoint = Index + 1; 00860 else 00861 { 00862 ERROR3IF(((Verbs[Index-1] & ~PT_CLOSEFIGURE) != PT_BEZIERTO),"Invalid path detected"); 00863 if ((Verbs[Index-1] & ~PT_CLOSEFIGURE) == PT_BEZIERTO) 00864 BezEndpoint = Index - 1; 00865 else 00866 NotFailed = FALSE; 00867 } 00868 00869 // Having found the endpoint attack its flags. 00870 if (NotFailed) 00871 { 00872 NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,BezEndpoint); 00873 } 00874 00875 // And the other control point if this is a closed path 00876 if (NotFailed && IsSubPathClosed) 00877 { 00878 if ( (Index == EndOfSubPathIndex-1) || (Index == EndOfSubPathIndex+1) ) 00879 NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,StartOfSubPathIndex); 00880 if ( (Index == StartOfSubPathIndex-1) || (Index == StartOfSubPathIndex+1) ) 00881 NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,EndOfSubPathIndex); 00882 } 00883 00884 // Clear them from the moved control point 00885 if (NotFailed) 00886 { 00887 NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,Index); 00888 } 00889 00890 // Also clear the flags from the opposite control point 00891 if (NotFailed) 00892 { 00893 INT32 OtherControlPoint = MyParams->PathToEdit->InkPath.FindOppositeControlPoint(Index); 00894 if (OtherControlPoint != -1) 00895 { 00896 NotFailed = ClearSmoothAndRotate(MyParams->PathToEdit,OtherControlPoint); 00897 } 00898 } 00899 } 00900 } 00901 00902 // Now run along the path and smooth it. 00903 if (NotFailed) 00904 { 00905 DocCoord NewCoord; 00906 for (INT32 i = 0; (i < NumElements) && NotFailed; i++) 00907 { 00908 if (Verbs[i] == PT_BEZIERTO && !(Flags[i].IsEndPoint) && Flags[i].IsSmooth) 00909 { 00910 NewCoord = MyParams->PathToEdit->InkPath.SmoothControlPoint(i); 00911 if (NewCoord != Coords[i]) 00912 NotFailed = DoAlterPathElement(MyParams->PathToEdit, i, NewCoord, Flags[i], Verbs[i]); 00913 } 00914 } 00915 } 00916 00917 if (NotFailed) 00918 GetApplication()->FindSelection()->UpdateBounds(); 00919 00920 if (!NotFailed) 00921 { 00922 InformError(); 00923 FailAndExecute(); 00924 } 00925 00926 End(); 00927 }
|
|
For finding the OpCyclePathSelectionFoward's state.
Reimplemented from TransOperation. Definition at line 755 of file pathops.cpp. 00756 { 00757 OpState OpSt; 00758 00759 return(OpSt); 00760 }
|
|
OpMovePathPoint initialiser method.
Reimplemented from SimpleCCObject. Definition at line 731 of file pathops.cpp. 00732 { 00733 return (RegisterOpDescriptor( 0, 00734 _R(IDS_MOVEPATHPOINT), 00735 CC_RUNTIME_CLASS(OpMovePathPoint), 00736 OPTOKEN_MOVEPATHPOINT, 00737 OpMovePathPoint::GetState, 00738 0, /* help ID */ 00739 _R(IDBBL_MOVEPATHPOINT), 00740 0 /* bitmap ID */)); 00741 }
|