QGIS API Documentation
2.2.0-Valmiera
|
Handles drawing of selection outlines and mouse handles. More...
#include <qgscomposermousehandles.h>
Public Types | |
enum | MouseAction { MoveItem, ResizeUp, ResizeDown, ResizeLeft, ResizeRight, ResizeLeftUp, ResizeRightUp, ResizeLeftDown, ResizeRightDown, SelectItem, NoAction } |
Describes the action (move or resize in different directon) to be done during mouse move. More... | |
enum | ItemPositionMode { UpperLeft, UpperMiddle, UpperRight, MiddleLeft, Middle, MiddleRight, LowerLeft, LowerMiddle, LowerRight } |
enum | SnapGuideMode { Item, Point } |
Public Slots | |
void | selectionChanged () |
Sets up listeners to sizeChanged signal for all selected items. | |
void | selectedItemSizeChanged () |
Redraws handles when selected item size changes. | |
void | selectedItemRotationChanged () |
Redraws handles when selected item rotation changes. |
Public Member Functions | |
QgsComposerMouseHandles (QgsComposition *composition) | |
virtual | ~QgsComposerMouseHandles () |
void | setComposition (QgsComposition *c) |
QgsComposition * | composition () |
void | paint (QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) |
QgsComposerMouseHandles::MouseAction | mouseActionForScenePos (const QPointF &sceneCoordPos) |
Finds out which mouse move action to choose depending on the scene cursor position. | |
bool | isDragging () |
Returns true is user is currently dragging the handles. | |
bool | isResizing () |
Returns true is user is currently resizing with the handles. |
Protected Member Functions | |
void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) |
void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) |
void | mousePressEvent (QGraphicsSceneMouseEvent *event) |
void | hoverMoveEvent (QGraphicsSceneHoverEvent *event) |
void | hoverLeaveEvent (QGraphicsSceneHoverEvent *event) |
Private Member Functions | |
QRectF | selectionBounds () const |
Returns the mouse handle bounds of current selection. | |
bool | selectionRotation (double &rotation) const |
Returns true if all selected items have same rotation, and if so, updates passed rotation variable. | |
void | updateHandles () |
Redraws or hides the handles based on the current selection. | |
void | drawHandles (QPainter *painter, double rectHandlerSize) |
Draws the handles. | |
void | drawSelectedItemBounds (QPainter *painter) |
Draw outlines for selected items. | |
double | rectHandlerBorderTolerance () |
Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the item border for resizing. | |
Qt::CursorShape | cursorForPosition (const QPointF &itemCoordPos) |
Finds out the appropriate cursor for the current mouse position in the widget (e.g. | |
QgsComposerMouseHandles::MouseAction | mouseActionForPosition (const QPointF &itemCoordPos) |
Finds out which mouse move action to choose depending on the cursor position inside the widget. | |
void | dragMouseMove (const QPointF ¤tPosition, bool lockMovement, bool preventSnap) |
Handles dragging of items during mouse move. | |
QSizeF | calcCursorEdgeOffset (const QPointF &cursorPos) |
Calculates the distance of the mouse cursor from thed edge of the mouse handles. | |
void | resizeMouseMove (const QPointF ¤tPosition, bool lockAspect, bool fromCenter) |
Handles resizing of items during mouse move. | |
QGraphicsLineItem * | hAlignSnapItem () |
Return horizontal align snap item. | |
void | deleteHAlignSnapItem () |
QGraphicsLineItem * | vAlignSnapItem () |
Return vertical align snap item. | |
void | deleteVAlignSnapItem () |
void | deleteAlignItems () |
QPointF | snapPoint (const QPointF &originalPoint, QgsComposerMouseHandles::SnapGuideMode mode) |
Snaps an item or point (depending on mode) originating at originalPoint to the grid or align rulers. | |
QPointF | alignItem (double &alignX, double &alignY, double unalignedX, double unalignedY) |
Snaps an item originating at unalignedX, unalignedY to the grid or align rulers. | |
QPointF | alignPos (const QPointF &pos, double &alignX, double &alignY) |
Snaps a point to to the grid or align rulers. | |
void | collectAlignCoordinates (QMap< double, const QgsComposerItem * > &alignCoordsX, QMap< double, const QgsComposerItem * > &alignCoordsY) |
bool | nearestItem (const QMap< double, const QgsComposerItem * > &coords, double value, double &nearestValue) const |
void | checkNearestItem (double checkCoord, const QMap< double, const QgsComposerItem * > &alignCoords, double &smallestDiff, double itemCoordOffset, double &itemCoord, double &alignCoord) const |
QGraphicsView * | graphicsView () |
void | setViewportCursor (Qt::CursorShape cursor) |
void | resetStatusBar () |
Private Attributes | |
QgsComposition * | mComposition |
QGraphicsView * | mGraphicsView |
QgsComposerMouseHandles::MouseAction | mCurrentMouseMoveAction |
QPointF | mMouseMoveStartPos |
Start point of the last mouse move action (in scene coordinates) | |
QPointF | mLastMouseEventPos |
Position of the last mouse move event (in scene coordinates) | |
QPointF | mBeginMouseEventPos |
Position of the mouse at beginning of move/resize (in scene coordinates) | |
QPointF | mBeginHandlePos |
Position of composer handles at beginning of move/resize (in scene coordinates) | |
double | mBeginHandleWidth |
Width and height of composer handles at beginning of resize. | |
double | mBeginHandleHeight |
QRectF | mResizeRect |
double | mResizeMoveX |
double | mResizeMoveY |
bool | mIsDragging |
True if user is currently dragging items. | |
bool | mIsResizing |
True is user is currently resizing items. | |
QGraphicsLineItem * | mHAlignSnapItem |
Align snap lines. | |
QGraphicsLineItem * | mVAlignSnapItem |
QSizeF | mCursorOffset |
Handles drawing of selection outlines and mouse handles.
Responsible for mouse interactions such as resizing and moving selected items.
Definition at line 31 of file qgscomposermousehandles.h.
UpperLeft | |
UpperMiddle | |
UpperRight | |
MiddleLeft | |
Middle | |
MiddleRight | |
LowerLeft | |
LowerMiddle | |
LowerRight |
Definition at line 52 of file qgscomposermousehandles.h.
Describes the action (move or resize in different directon) to be done during mouse move.
MoveItem | |
ResizeUp | |
ResizeDown | |
ResizeLeft | |
ResizeRight | |
ResizeLeftUp | |
ResizeRightUp | |
ResizeLeftDown | |
ResizeRightDown | |
SelectItem | |
NoAction |
Definition at line 37 of file qgscomposermousehandles.h.
Definition at line 65 of file qgscomposermousehandles.h.
QgsComposerMouseHandles::QgsComposerMouseHandles | ( | QgsComposition * | composition | ) |
Definition at line 29 of file qgscomposermousehandles.cpp.
References mComposition, and selectionChanged().
|
virtual |
Definition at line 49 of file qgscomposermousehandles.cpp.
|
private |
Snaps an item originating at unalignedX, unalignedY to the grid or align rulers.
Definition at line 1158 of file qgscomposermousehandles.cpp.
References checkNearestItem(), and collectAlignCoordinates().
Referenced by snapPoint().
|
private |
Snaps a point to to the grid or align rulers.
Definition at line 1196 of file qgscomposermousehandles.cpp.
References QgsComposition::alignmentSnapTolerance(), collectAlignCoordinates(), mComposition, and nearestItem().
Referenced by snapPoint().
|
private |
Calculates the distance of the mouse cursor from thed edge of the mouse handles.
Definition at line 728 of file qgscomposermousehandles.cpp.
References mCurrentMouseMoveAction, ResizeDown, ResizeLeft, ResizeLeftDown, ResizeLeftUp, ResizeRight, ResizeRightDown, ResizeRightUp, and ResizeUp.
Referenced by mousePressEvent().
|
private |
Definition at line 1292 of file qgscomposermousehandles.cpp.
References nearestItem().
Referenced by alignItem().
|
private |
Definition at line 1235 of file qgscomposermousehandles.cpp.
References QgsComposition::alignmentSnap(), mComposition, qgsDoubleNear(), QgsComposerItem::rectWithFrame(), QgsComposerItem::selected(), QgsComposition::smartGuidesEnabled(), and QgsComposition::snapLines().
Referenced by alignItem(), and alignPos().
|
inline |
Definition at line 75 of file qgscomposermousehandles.h.
Referenced by selectionChanged().
|
private |
Finds out the appropriate cursor for the current mouse position in the widget (e.g.
move in the middle, resize at border)
Definition at line 341 of file qgscomposermousehandles.cpp.
References mouseActionForPosition(), MoveItem, NoAction, ResizeDown, ResizeLeft, ResizeLeftDown, ResizeLeftUp, ResizeRight, ResizeRightDown, ResizeRightUp, ResizeUp, and SelectItem.
Referenced by hoverMoveEvent().
|
private |
Definition at line 1152 of file qgscomposermousehandles.cpp.
References deleteHAlignSnapItem(), and deleteVAlignSnapItem().
Referenced by dragMouseMove(), mousePressEvent(), mouseReleaseEvent(), and snapPoint().
|
private |
Definition at line 1132 of file qgscomposermousehandles.cpp.
References mHAlignSnapItem.
Referenced by deleteAlignItems(), and snapPoint().
|
private |
Definition at line 1142 of file qgscomposermousehandles.cpp.
References mVAlignSnapItem.
Referenced by deleteAlignItems(), and snapPoint().
|
private |
Handles dragging of items during mouse move.
Definition at line 768 of file qgscomposermousehandles.cpp.
References deleteAlignItems(), Item, mBeginHandlePos, mBeginMouseEventPos, mComposition, QgsComposition::setStatusMessage(), snapPoint(), and tr.
Referenced by mouseMoveEvent().
|
private |
Draws the handles.
Definition at line 96 of file qgscomposermousehandles.cpp.
Referenced by paint().
|
private |
Draw outlines for selected items.
Definition at line 127 of file qgscomposermousehandles.cpp.
References mBeginHandleHeight, mBeginHandleWidth, mComposition, mIsDragging, mIsResizing, mResizeMoveX, mResizeMoveY, mResizeRect, QgsComposition::relativeResizeRect(), and QgsComposition::selectedComposerItems().
Referenced by paint().
|
private |
Definition at line 54 of file qgscomposermousehandles.cpp.
References mGraphicsView.
Referenced by rectHandlerBorderTolerance(), and setViewportCursor().
|
private |
Return horizontal align snap item.
Creates a new graphics line if 0
Definition at line 1108 of file qgscomposermousehandles.cpp.
References mHAlignSnapItem.
Referenced by snapPoint().
|
protected |
Definition at line 527 of file qgscomposermousehandles.cpp.
References setViewportCursor().
|
protected |
Definition at line 522 of file qgscomposermousehandles.cpp.
References cursorForPosition(), and setViewportCursor().
|
inline |
Returns true is user is currently dragging the handles.
Definition at line 83 of file qgscomposermousehandles.h.
Referenced by QgsComposerView::mouseReleaseEvent().
|
inline |
Returns true is user is currently resizing with the handles.
Definition at line 86 of file qgscomposermousehandles.h.
Referenced by QgsComposerView::mouseReleaseEvent().
|
private |
Finds out which mouse move action to choose depending on the cursor position inside the widget.
Definition at line 433 of file qgscomposermousehandles.cpp.
References mComposition, MoveItem, rectHandlerBorderTolerance(), ResizeDown, ResizeLeft, ResizeLeftDown, ResizeLeftUp, ResizeRight, ResizeRightDown, ResizeRightUp, ResizeUp, QgsComposerItem::selected(), and SelectItem.
Referenced by cursorForPosition(), mouseActionForScenePos(), and mousePressEvent().
QgsComposerMouseHandles::MouseAction QgsComposerMouseHandles::mouseActionForScenePos | ( | const QPointF & | sceneCoordPos | ) |
Finds out which mouse move action to choose depending on the scene cursor position.
Definition at line 515 of file qgscomposermousehandles.cpp.
References mouseActionForPosition().
Referenced by QgsComposerView::mousePressEvent().
|
protected |
Definition at line 544 of file qgscomposermousehandles.cpp.
References dragMouseMove(), mIsDragging, mIsResizing, mLastMouseEventPos, and resizeMouseMove().
|
protected |
Definition at line 694 of file qgscomposermousehandles.cpp.
References calcCursorEdgeOffset(), deleteAlignItems(), mBeginHandleHeight, mBeginHandlePos, mBeginHandleWidth, mBeginMouseEventPos, mCurrentMouseMoveAction, mCursorOffset, mIsDragging, mIsResizing, mLastMouseEventPos, mMouseMoveStartPos, mouseActionForPosition(), MoveItem, mResizeMoveX, mResizeMoveY, mResizeRect, NoAction, and SelectItem.
|
protected |
Definition at line 573 of file qgscomposermousehandles.cpp.
References deleteAlignItems(), mBeginHandleHeight, mBeginHandlePos, mBeginHandleWidth, mComposition, mCurrentMouseMoveAction, MathUtils::min(), mIsDragging, mIsResizing, mMouseMoveStartPos, MoveItem, mResizeMoveX, mResizeMoveY, mResizeRect, NoAction, QgsComposition::relativeResizeRect(), resetStatusBar(), QgsComposerItemCommand::saveAfterState(), QgsComposerItemCommand::savePreviousState(), QgsComposition::selectedComposerItems(), setViewportCursor(), tr, QgsComposition::undoStack(), updateHandles(), and UpperLeft.
|
private |
Definition at line 1309 of file qgscomposermousehandles.cpp.
Referenced by alignPos(), and checkNearestItem().
void QgsComposerMouseHandles::paint | ( | QPainter * | painter, |
const QStyleOptionGraphicsItem * | itemStyle, | ||
QWidget * | pWidget | ||
) |
Definition at line 77 of file qgscomposermousehandles.cpp.
References drawHandles(), drawSelectedItemBounds(), mComposition, QgsComposition::plotStyle(), QgsComposition::Preview, and rectHandlerBorderTolerance().
|
private |
Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the item border for resizing.
Definition at line 320 of file qgscomposermousehandles.cpp.
References graphicsView().
Referenced by mouseActionForPosition(), and paint().
|
private |
Definition at line 673 of file qgscomposermousehandles.cpp.
References mComposition, QgsComposition::selectedComposerItems(), QgsComposition::setStatusMessage(), and tr.
Referenced by mouseReleaseEvent(), and selectionChanged().
|
private |
Handles resizing of items during mouse move.
Definition at line 822 of file qgscomposermousehandles.cpp.
References mBeginHandleHeight, mBeginHandleWidth, mBeginMouseEventPos, mComposition, mCurrentMouseMoveAction, mCursorOffset, MoveItem, mResizeMoveX, mResizeMoveY, mResizeRect, NoAction, Point, ResizeDown, ResizeLeft, ResizeLeftDown, ResizeLeftUp, ResizeRight, ResizeRightDown, ResizeRightUp, ResizeUp, SelectItem, QgsComposition::setStatusMessage(), snapPoint(), and tr.
Referenced by mouseMoveEvent().
|
slot |
Redraws handles when selected item rotation changes.
Definition at line 228 of file qgscomposermousehandles.cpp.
References mIsDragging, mIsResizing, and updateHandles().
Referenced by selectionChanged().
|
slot |
Redraws handles when selected item size changes.
Definition at line 219 of file qgscomposermousehandles.cpp.
References mIsDragging, mIsResizing, and updateHandles().
Referenced by selectionChanged().
|
private |
Returns the mouse handle bounds of current selection.
Definition at line 278 of file qgscomposermousehandles.cpp.
References mComposition, and QgsComposition::selectedComposerItems().
Referenced by updateHandles().
|
slot |
Sets up listeners to sizeChanged signal for all selected items.
Definition at line 190 of file qgscomposermousehandles.cpp.
References composition(), resetStatusBar(), QgsComposerItem::selected(), selectedItemRotationChanged(), selectedItemSizeChanged(), and updateHandles().
Referenced by QgsComposerMouseHandles().
|
private |
Returns true if all selected items have same rotation, and if so, updates passed rotation variable.
Definition at line 296 of file qgscomposermousehandles.cpp.
References mComposition, and QgsComposition::selectedComposerItems().
Referenced by updateHandles().
|
inline |
Definition at line 74 of file qgscomposermousehandles.h.
|
private |
Definition at line 533 of file qgscomposermousehandles.cpp.
References graphicsView(), mComposition, and QgsComposition::preventCursorChange().
Referenced by hoverLeaveEvent(), hoverMoveEvent(), and mouseReleaseEvent().
|
private |
Snaps an item or point (depending on mode) originating at originalPoint to the grid or align rulers.
Definition at line 1048 of file qgscomposermousehandles.cpp.
References alignItem(), QgsComposition::alignmentSnap(), alignPos(), deleteAlignItems(), deleteHAlignSnapItem(), deleteVAlignSnapItem(), hAlignSnapItem(), Item, mComposition, QgsComposition::numPages(), QgsComposition::paperHeight(), QgsComposition::paperWidth(), Point, QgsComposition::smartGuidesEnabled(), QgsComposition::snapPointToGrid(), QgsComposition::spaceBetweenPages(), and vAlignSnapItem().
Referenced by dragMouseMove(), and resizeMouseMove().
|
private |
Redraws or hides the handles based on the current selection.
Definition at line 237 of file qgscomposermousehandles.cpp.
References mComposition, QgsComposition::selectedComposerItems(), selectionBounds(), and selectionRotation().
Referenced by mouseReleaseEvent(), selectedItemRotationChanged(), selectedItemSizeChanged(), and selectionChanged().
|
private |
Return vertical align snap item.
Creates a new graphics line if 0
Definition at line 1120 of file qgscomposermousehandles.cpp.
References mVAlignSnapItem.
Referenced by snapPoint().
|
private |
Definition at line 123 of file qgscomposermousehandles.h.
Referenced by drawSelectedItemBounds(), mousePressEvent(), mouseReleaseEvent(), and resizeMouseMove().
|
private |
Position of composer handles at beginning of move/resize (in scene coordinates)
Definition at line 120 of file qgscomposermousehandles.h.
Referenced by dragMouseMove(), mousePressEvent(), and mouseReleaseEvent().
|
private |
Width and height of composer handles at beginning of resize.
Definition at line 122 of file qgscomposermousehandles.h.
Referenced by drawSelectedItemBounds(), mousePressEvent(), mouseReleaseEvent(), and resizeMouseMove().
|
private |
Position of the mouse at beginning of move/resize (in scene coordinates)
Definition at line 118 of file qgscomposermousehandles.h.
Referenced by dragMouseMove(), mousePressEvent(), and resizeMouseMove().
|
private |
Definition at line 109 of file qgscomposermousehandles.h.
Referenced by alignPos(), collectAlignCoordinates(), dragMouseMove(), drawSelectedItemBounds(), mouseActionForPosition(), mouseReleaseEvent(), paint(), QgsComposerMouseHandles(), resetStatusBar(), resizeMouseMove(), selectionBounds(), selectionRotation(), setViewportCursor(), snapPoint(), and updateHandles().
|
private |
Definition at line 112 of file qgscomposermousehandles.h.
Referenced by calcCursorEdgeOffset(), mousePressEvent(), mouseReleaseEvent(), and resizeMouseMove().
|
private |
Definition at line 138 of file qgscomposermousehandles.h.
Referenced by mousePressEvent(), and resizeMouseMove().
|
private |
Definition at line 110 of file qgscomposermousehandles.h.
Referenced by graphicsView().
|
private |
Align snap lines.
Definition at line 135 of file qgscomposermousehandles.h.
Referenced by deleteHAlignSnapItem(), and hAlignSnapItem().
|
private |
True if user is currently dragging items.
Definition at line 130 of file qgscomposermousehandles.h.
Referenced by drawSelectedItemBounds(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), selectedItemRotationChanged(), and selectedItemSizeChanged().
|
private |
True is user is currently resizing items.
Definition at line 132 of file qgscomposermousehandles.h.
Referenced by drawSelectedItemBounds(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), selectedItemRotationChanged(), and selectedItemSizeChanged().
|
private |
Position of the last mouse move event (in scene coordinates)
Definition at line 116 of file qgscomposermousehandles.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
|
private |
Start point of the last mouse move action (in scene coordinates)
Definition at line 114 of file qgscomposermousehandles.h.
Referenced by mousePressEvent(), and mouseReleaseEvent().
|
private |
Definition at line 126 of file qgscomposermousehandles.h.
Referenced by drawSelectedItemBounds(), mousePressEvent(), mouseReleaseEvent(), and resizeMouseMove().
|
private |
Definition at line 127 of file qgscomposermousehandles.h.
Referenced by drawSelectedItemBounds(), mousePressEvent(), mouseReleaseEvent(), and resizeMouseMove().
|
private |
Definition at line 125 of file qgscomposermousehandles.h.
Referenced by drawSelectedItemBounds(), mousePressEvent(), mouseReleaseEvent(), and resizeMouseMove().
|
private |
Definition at line 136 of file qgscomposermousehandles.h.
Referenced by deleteVAlignSnapItem(), and vAlignSnapItem().