#include <slicetool.h>
Inheritance diagram for OpSliceTranslate:
Public Member Functions | |
OpSliceTranslate () | |
Constructor. | |
virtual BOOL | ShouldPointerBeOffset () |
Tells the base class of the operation that we want our mouse coords to be left alone. | |
virtual void | DragStarted (TransformData *, DragTool *, TransformBoundingData *, DocCoord, Spread *, ClickModifiers, DocCoord ClickOffset=DocCoord(0, 0), Node *NodeToTrans=NULL, DragType dragtype=DRAGTYPE_AUTOSCROLL) |
When we start a drag, we want to compile a list of bounding boxes which belong to non-selected named sets, eg if there is a group of objects called 'Button One' and it is not selected, we want to add its overall bounding box to a list, so we can collision detect against it later. | |
virtual void | DragFinished (DocCoord, ClickModifiers, Spread *, BOOL, BOOL bSolidDrag) |
Called when the selection-drag finishes, either normally or having been cancelled by the user. Performs tidy-up when the drag is over. | |
Static Public Member Functions | |
static BOOL | Declare () |
Adds the operation to the list of all known operations. | |
Protected Member Functions | |
void | CompileCollisionBoxList () |
Make a list of the overall bounding rects of all named sets which have no members selected. These are used to collision detect against during the drag. | |
BOOL | TestBoundingBoxCollision (DocRect *pTestRect, Spread *pSpread) |
Test the given bounding rect against the list of bounding rects, m_lBoxes, and return TRUE if it overlaps any of them. | |
BOOL | SnapRectToBoxList (Spread *pSpread, DocRect *pDocRect, const DocCoord &PrevCoord, const DocCoord &CurCoord) |
Protected Attributes | |
List | m_lBoxes |
BOOL | m_bDrawingBlobs |
DocRect | m_DragRect |
Private Member Functions | |
CC_DECLARE_DYNCREATE (OpSliceTranslate) | |
virtual void | InitTransformImmediate (OpParam *) |
Sets up the transform ready for an immediate translation. This is called from DoWithParam(). | |
virtual void | InitTransformOnDrag (DocCoord, ClickModifiers) |
Sets up the parameters needed to build the transform matrix at the start of the drag. The base class version of this function does nothing. | |
virtual void | UpdateTransformOnDrag (DocCoord, Spread *, ClickModifiers &) |
Updates the op's state variables (eg selection bounding rect) and its blobs whenever the mouse moves. | |
virtual void | BuildMatrix () |
Builds the transform matrix required to rotate the selection about the point CentreOfRot by the required number of degrees. | |
virtual void | ConstrainDrag (DocCoord *) |
Will constrain the mouse position to lie along rays from the centre of rotation at the constrain angle apart (45 degrees by default). | |
virtual BOOL | CanChangeSpread () |
Tell the baseclass functions whether to draw drag feedback only on the start spread or to allow drag rendering to be done on other spreads too. | |
Private Attributes | |
DocCoord | LastPos |
DocCoord | OriginalGridOffset |
Definition at line 498 of file slicetool.h.
|
Constructor.
Definition at line 3508 of file slicetool.cpp. 03508 : TransOperation() 03509 { 03510 //Set status line help 03511 StatusHelpID = _R(IDS_TRANSLTRANS_STATUS1); 03512 StatusHelpID2 = _R(IDS_TRANSLTRANS_STATUS2); 03513 CanScaleLines = FALSE; 03514 }
|
|
Builds the transform matrix required to rotate the selection about the point CentreOfRot by the required number of degrees.
Reimplemented from TransOperation. Definition at line 3778 of file slicetool.cpp. 03779 { 03780 // Build a translation matrix by takeing the offset from the last mouse position 03781 // to the start mouse position 03782 Transform = Matrix(LastPos.x-GetStartPos().x, LastPos.y-GetStartPos().y); 03783 }
|
|
Tell the baseclass functions whether to draw drag feedback only on the start spread or to allow drag rendering to be done on other spreads too.
Reimplemented from TransOperation. Definition at line 3717 of file slicetool.cpp. 03718 { 03719 return TRUE; 03720 }
|
|
|
|
Make a list of the overall bounding rects of all named sets which have no members selected. These are used to collision detect against during the drag.
Definition at line 3865 of file slicetool.cpp. 03866 { 03867 // iterate through the current list of named sets. if a named set 03868 // has no objects selected, then add its collective bounding rect 03869 // to the list of bounding rects, for collision detection. 03870 NameGallery * pNameGallery = NameGallery::Instance(); 03871 //pNameGallery->ForceUpdate(); 03872 SGUsedNames* pNames = pNameGallery ? pNameGallery->GetUsedNames() : NULL; 03873 SGNameItem* pItem = pNames ? (SGNameItem*) pNames->GetChild() : NULL; 03874 03875 m_lBoxes.DeleteAll(); 03876 while (pItem != NULL) 03877 { 03878 if (pItem->IsNoneSelected()) 03879 m_lBoxes.AddTail(new RectListItem(pItem->GetSetBounds())); 03880 03881 // get next name. 03882 pItem = (SGNameItem*)pItem->GetNext(); 03883 } 03884 }
|
|
Will constrain the mouse position to lie along rays from the centre of rotation at the constrain angle apart (45 degrees by default).
Reimplemented from TransOperation. Definition at line 3820 of file slicetool.cpp. 03821 { 03822 // Lock the mouse to move along the axis or diagonally 03823 DocCoord Blobby = GetStartPos(); 03824 DocView::ConstrainToAngle(Blobby, PointerPos); 03825 }
|
|
Adds the operation to the list of all known operations.
Reimplemented from TransOperation. Definition at line 3840 of file slicetool.cpp. 03841 { 03842 return (RegisterOpDescriptor(0, _R(IDS_SLICE_MOVE), CC_RUNTIME_CLASS(OpSliceTranslate), 03843 OPTOKEN_SLICE_TRANSLATE, TransOperation::GetState)); 03844 }
|
|
Called when the selection-drag finishes, either normally or having been cancelled by the user. Performs tidy-up when the drag is over.
Reimplemented from TransOperation. Definition at line 4006 of file slicetool.cpp. 04008 { 04009 // have we finished drawing blobs, or do we need to erase them? 04010 if (m_bDrawingBlobs) 04011 { 04012 RenderDragBlobs(m_DragRect, StartSpread, bSolidDrag); // erase them. 04013 TransOperation::RenderDragBlobs(m_DragRect, StartSpread, bSolidDrag); 04014 } 04015 04016 m_lBoxes.DeleteAll(); 04017 TransOperation::DragFinished(dcPos, ClickMods, pSpread, bSuccess, bSolidDrag); 04018 }
|
|
When we start a drag, we want to compile a list of bounding boxes which belong to non-selected named sets, eg if there is a group of objects called 'Button One' and it is not selected, we want to add its overall bounding box to a list, so we can collision detect against it later.
Definition at line 3962 of file slicetool.cpp. 03971 { 03972 // compile a list of any names which are *not* used by the current selection, 03973 // and use this to compile a list of bounding boxes which we can collision-test 03974 // against during the drag, to announce if we cross any other named sets. 03975 CompileCollisionBoxList(); 03976 m_bDrawingBlobs = FALSE; 03977 03978 // call the base-class drag-start routine. 03979 TransOperation::DragStarted(TransData, pTool, pBounds, ClickPos, pSpread, ClickMods, 03980 ClickOffset, NodeToTransform, dragtype); 03981 }
|
|
Sets up the transform ready for an immediate translation. This is called from DoWithParam().
Reimplemented from TransOperation. Definition at line 3532 of file slicetool.cpp. 03533 { 03534 // Set the initial position 03535 StartPos = DocCoord(0,0); 03536 RawStartPos = StartPos; 03537 MagStartPos = StartPos; 03538 03539 // and copy the offset to translate by from Param2 03540 DocCoord* Offset = (DocCoord*)(pOpParam->Param2); 03541 LastPos.x = Offset->x; 03542 LastPos.y = Offset->y; 03543 03544 OriginalGridOffset.x=0; 03545 OriginalGridOffset.y=0; 03546 }
|
|
Sets up the parameters needed to build the transform matrix at the start of the drag. The base class version of this function does nothing.
Reimplemented from TransOperation. Definition at line 3562 of file slicetool.cpp. 03563 { 03564 // make a note of the current mouse position 03565 LastPos = PointerPos; 03566 03567 // Record the offset from the mouse pos to the grid 03568 OriginalGridOffset = GetStartPos(); 03569 DocView::ForceSnapToGrid(StartSpread, &OriginalGridOffset); 03570 OriginalGridOffset = GetStartPos() - OriginalGridOffset; 03571 }
|
|
Tells the base class of the operation that we want our mouse coords to be left alone.
Reimplemented from TransOperation. Definition at line 3799 of file slicetool.cpp. 03800 { 03801 return FALSE; 03802 }
|
|
This function does not live with all the other snap functions because it's use is restricted solely to the context of this operation.
Definition at line 3749 of file slicetool.cpp. 03752 { 03753 // iterate over our list of rectangles and check pDocRect against each one. 03754 BOOL bSnapped = FALSE; 03755 RectListItem* pCurListItem = (RectListItem*)m_lBoxes.GetHead(); 03756 while (!bSnapped && pCurListItem != NULL) 03757 { 03758 bSnapped = CSnap::SnapRectToRect(pDocRect, pCurListItem->GetRect()); 03759 pCurListItem = (RectListItem*)m_lBoxes.GetNext(pCurListItem); 03760 } 03761 03762 return bSnapped; 03763 }
|
|
Test the given bounding rect against the list of bounding rects, m_lBoxes, and return TRUE if it overlaps any of them.
Additional: Karim MacDonald 07/02/2000 This function now always returns FALSE, to prevent visual artifacts when dragging with the slice-tool, a result of the re-introduction of a dashed line around the selection during a drag.
Definition at line 3914 of file slicetool.cpp. 03915 { 03916 ERROR2IF(pTestRect == NULL || pSpread == NULL, FALSE, 03917 "OpSliceTranslate::TestBoundingBoxCollision- called with a NULL parameter"); 03918 03919 // iterate over the list, checking each rect against pTestRect. 03920 RectListItem* pListItem = (RectListItem*)m_lBoxes.GetHead(); 03921 BOOL bCollision = FALSE; 03922 while (!bCollision && pListItem != NULL) 03923 { 03924 bCollision = pTestRect->IsIntersectedWith(pListItem->GetRect()); 03925 03926 // get the next object in the list. 03927 if (!bCollision) 03928 pListItem = (RectListItem*)m_lBoxes.GetNext(pListItem); 03929 } 03930 03931 // return bCollision; 03932 return FALSE; 03933 }
|
|
Updates the op's state variables (eg selection bounding rect) and its blobs whenever the mouse moves.
Reimplemented from TransOperation. Definition at line 3589 of file slicetool.cpp. 03591 { 03592 // get the bounding box of the dragged selection and update it's position. 03593 DocCoord Offset = PointerPos - LastPos; 03594 DocRect Bounds( BoundingData.x, BoundingData.y, 03595 BoundingData.x+BoundingData.Width, 03596 BoundingData.y+BoundingData.Height ); 03597 Bounds.lo = Bounds.lo + Offset; 03598 Bounds.hi = Bounds.hi + Offset; 03599 DocRect SnappedBounds = Bounds; 03600 03601 // if this drag is not being constrained, then see if we can snap to anything. 03602 if (!ClickMods.Constrain) 03603 { 03604 // Apply snapping to the pointer pos 03605 // First apply magnetic snapping alone 03606 if (MagneticGripPoint && DocView::SnapSelected(pSpread, &PointerPos, TRUE, FALSE)) 03607 { 03608 // Magnetic snapping worked! 03609 } 03610 else 03611 { 03612 // Magnetic snapping failed! 03613 03614 // If magnetic snapping failed then try grid snapping 03615 // on the adjusted coordinate 03616 if (ClickMods.Alternative1) 03617 { 03618 PointerPos = PointerPos - OriginalGridOffset; 03619 DocView::SnapSelected(pSpread, &PointerPos, FALSE, TRUE); 03620 PointerPos = PointerPos + OriginalGridOffset; 03621 } 03622 03623 // ok, try snapping the selection's bounds to anything in the document, 03624 // eg guidelines, other objects etc. 03625 else 03626 { 03627 if (DocView::SnapSelected(pSpread,&SnappedBounds,LastRawPos,RawPos)) 03628 PointerPos = PointerPos + (SnappedBounds.lo - Bounds.lo); 03629 03630 // right, nothing else has worked - how about trying to snap our bounding 03631 // rect to one of the bounding rects in our list? 03632 else 03633 { 03634 if (SnapRectToBoxList(pSpread, &SnappedBounds, LastRawPos, RawPos)) 03635 PointerPos = PointerPos + (SnappedBounds.lo - Bounds.lo); 03636 } 03637 } 03638 } 03639 } 03640 03641 // Update BoundingData's offset information and pass it to Bounds. 03642 INT32 dx = PointerPos.x - LastPos.x; 03643 INT32 dy = PointerPos.y - LastPos.y; 03644 BoundingData.x += dx; 03645 BoundingData.y += dy; 03646 BoundingData.XYChanged = TRUE; 03647 Bounds.lox = BoundingData.x; 03648 Bounds.loy = BoundingData.y; 03649 Bounds.hix = BoundingData.x + BoundingData.Width; 03650 Bounds.hiy = BoundingData.y + BoundingData.Height; 03651 03652 // do a collision-detection between the selection bounding rect and a list 03653 // of named-set bounding rect's we built at the start of the drag. 03654 // highlight our selection bounding rect if we collide. 03655 if (TestBoundingBoxCollision(&Bounds, pSpread)) 03656 { 03657 // new collision? if so, draw fresh blobs. 03658 if (!m_bDrawingBlobs) 03659 { 03660 m_DragRect = Bounds; 03661 m_bDrawingBlobs = TRUE; 03662 RenderDragBlobs(m_DragRect, StartSpread, FALSE); 03663 } 03664 03665 // otherwise, update the current blobs. 03666 else 03667 { 03668 // rub out old collision blobs. 03669 RenderDragBlobs(m_DragRect, StartSpread, FALSE); 03670 03671 // update the record of the selection bounds. 03672 m_DragRect = Bounds; 03673 03674 // draw new collision blobs. 03675 RenderDragBlobs(m_DragRect, StartSpread, FALSE); 03676 } 03677 } 03678 03679 // we're not presently colliding, so if we have to then 03680 // rub out any old blobs and invalidate the drag-rect. 03681 else 03682 { 03683 if (m_bDrawingBlobs) 03684 { 03685 // don't render the blobs from here anymore, and render them off. 03686 m_bDrawingBlobs = FALSE; 03687 RenderDragBlobs(m_DragRect, StartSpread, FALSE); 03688 03689 // invalidate the drag-rect, so that it won't be rendered from RenderDragBlobs(). 03690 m_DragRect.hix = m_DragRect.lox - 1; 03691 } 03692 } 03693 03694 // Make a mental note of the current position 03695 LastPos = PointerPos; 03696 03697 // Update the current spread (must do this if CanChangeSpread returns TRUE) 03698 CurrentSpread = pSpread; 03699 }
|
|
Definition at line 564 of file slicetool.h. |
|
Definition at line 560 of file slicetool.h. |
|
Definition at line 561 of file slicetool.h. |
|
Definition at line 556 of file slicetool.h. |
|
Definition at line 565 of file slicetool.h. |