#include <penedit.h>
Inheritance diagram for OpPenAddElement:
Public Member Functions | |
OpPenAddElement () | |
OpPenAddElement constructor. | |
void | DoPenAddElement (NodePath *, INT32, DocCoord, Spread *, Path *) |
This function starts of the dragging of a new path element which will be added to the path held within pNode. The add position is taken as the paths CurrentPosition variable. | |
virtual void | DragFinished (DocCoord Pos, ClickModifiers Mods, Spread *pSpread, BOOL Success, BOOL bSolidDrag) |
This is called when a drag operation finishes. | |
Static Public Member Functions | |
static BOOL | Init () |
OpPenAddElement initialiser method. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
For finding the OpPenAddElement's state. | |
Private Attributes | |
NodePath * | pEditNode |
INT32 | EditIndex |
Definition at line 447 of file penedit.h.
|
OpPenAddElement constructor.
Definition at line 1707 of file penedit.cpp.
|
|
This function starts of the dragging of a new path element which will be added to the path held within pNode. The add position is taken as the paths CurrentPosition variable.
Definition at line 1800 of file penedit.cpp. 01805 { 01806 // right we need to build a new path element, whose start coordinate and control is 01807 // determined by the end element of the passed docpath. 01808 // here are the rules for element addition 01809 // (1) A curve is always added, and possibly converted to a line at the end 01810 // of the drag 01811 // (2) The curve elements smoothness is controled by the previous path elements 01812 // smoothness. ie if we are adding to a smooth end point then the element 01813 // we create will form a smooth join. 01814 // (3) If the previous element is a line, we will create either a none smooth 01815 // curve or another line, dependent on the drag. 01816 01817 BOOL ok = FALSE; 01818 pEditPath = pPath; 01819 pEditNode = pNode; 01820 EditIndex = Attach; 01821 01822 // Make sure the click point is in the correct coordinate system 01823 Spread* pPathSpread = pNode->FindParentSpread(); 01824 if (pPathSpread != pClickSpread) 01825 ClickPoint = MakeRelativeToSpread(pPathSpread, pClickSpread, ClickPoint); 01826 01827 // Get some interresting details about the path... 01828 Path* pDocPath = &(pNode->InkPath); 01829 INT32 ncoords = pDocPath->GetNumCoords(); 01830 01831 pDocPath->SetPathPosition(EditIndex); 01832 01833 // Ensure things are in range and sensible 01834 if (ncoords<=0) 01835 { 01836 FailAndExecute(); 01837 End(); 01838 return; 01839 } 01840 01841 // Read the attach point control details 01842 DocCoord AttachC = pDocPath->GetCoord(); 01843 PathVerb AttachV = pDocPath->GetVerb(); 01844 PathFlags AttachF = pDocPath->GetFlags(); 01845 01846 WobbleFlags wFlags; 01847 01848 // Make sure we get the grid snapping involved 01849 DocCoord SnapPos = ClickPoint; 01850 DocView::SnapCurrent(pClickSpread,&SnapPos); 01851 01852 // now create an element dependent on the control point type 01853 01854 switch (AttachV) 01855 { 01856 case PT_MOVETO: 01857 // Nasty option to control adding paths to the begining of the path 01858 { 01859 pDocPath->SetPathPosition(EditIndex+1); 01860 DocCoord NextC = pDocPath->GetCoord(); 01861 PathFlags NextF = pDocPath->GetFlags(); 01862 01863 if (NextF.IsRotate) 01864 ok = InsertGhostedBezier(NextC, AttachC, SnapPos); 01865 else 01866 { 01867 wFlags.PrevSister = TRUE; 01868 ok = InsertCurvedLine(AttachC, SnapPos); 01869 } 01870 } 01871 break; 01872 01873 01874 case PT_BEZIERTO: 01875 { 01876 pDocPath->SetPathPosition(EditIndex-1); 01877 DocCoord PrevC = pDocPath->GetCoord(); 01878 01879 if (AttachF.IsRotate) 01880 ok = InsertGhostedBezier(PrevC, AttachC, SnapPos); 01881 else 01882 { 01883 wFlags.PrevSister = TRUE; 01884 ok = InsertCurvedLine(AttachC, SnapPos); 01885 } 01886 } 01887 break; 01888 01889 01890 case PT_LINETO: 01891 { 01892 wFlags.PrevSister = TRUE; 01893 ok = InsertCurvedLine(AttachC, SnapPos); 01894 } 01895 break; 01896 } 01897 01898 if (ok) 01899 { 01900 // if we've created the element, set the wobble flags 01901 SetWobbleIndex(wFlags,3); 01902 01903 // Save info about the click point and spread 01904 HandleFlags hFlags; 01905 SetDragHandles(hFlags, SnapPos, SnapPos, SnapPos, pClickSpread); 01906 01907 // Render the first eor version on 01908 DocRect Rect = GetBoundingRect(); 01909 RenderDragBlobs(Rect, StartSpread, FALSE); 01910 01911 // now attempt to start the drag 01912 ok = OpPenEditPath::DoPenDragPath(); 01913 } 01914 01915 if (!ok) 01916 { 01917 // failed to perform create so lets tidy up the path and exit 01918 pEditPath->ClearPath(); 01919 FailAndExecute(); 01920 End(); 01921 } 01922 }
|
|
This is called when a drag operation finishes.
Reimplemented from OpPenEditPath. Definition at line 1943 of file penedit.cpp. 01945 { 01946 // inform the base class to stop dragging 01947 OpPenEditPath::DragFinished( PointerPos, ClickMods, pSpread, Success, bSolidDrag); 01948 01949 // Rub out the old EORed version of the path 01950 DocRect Rect = GetBoundingRect(); 01951 RenderDragBlobs( Rect, StartSpread, bSolidDrag); 01952 01953 if (Success) 01954 { 01955 // if the mouse hasn't moved make the curve into a path 01956 if (!HasMouseMoved(StartMousePos,CurrentMousePos)) 01957 ConvertPathEnd(&(pEditNode->InkPath)); 01958 01959 // if we're adding to the start of a subpath, reverse our edited path 01960 PathVerb* verbs = pEditNode->InkPath.GetVerbArray(); 01961 if (verbs[EditIndex] == PT_MOVETO) 01962 pEditPath->Reverse(); 01963 } 01964 else 01965 FailAndExecute(); 01966 01967 // Once done remove the edit path 01968 End(); 01969 }
|
|
For finding the OpPenAddElement's state.
Reimplemented from OpPenEditPath. Definition at line 1763 of file penedit.cpp. 01764 { 01765 OpState OpSt; 01766 // Always enabled at the moment. 01767 return OpSt; 01768 }
|
|
OpPenAddElement initialiser method.
Reimplemented from OpPenEditPath. Definition at line 1731 of file penedit.cpp. 01732 { 01733 return (RegisterOpDescriptor(0, // tool ID 01734 _R(IDS_PENADDELEMENTOP), // string resource ID 01735 CC_RUNTIME_CLASS(OpPenAddElement), // runtime class for Op 01736 OPTOKEN_PENADDELEMENT, // Ptr to token string 01737 OpPenAddElement::GetState, // GetState function 01738 0, // help ID = 0 01739 _R(IDBBL_PENADDELEMENTOP), // bubble help ID = 0 01740 0 // resource ID = 0 01741 )); 01742 01743 }
|
|
|
|
|