AlbumShaper
1.0a3
|
Display widget for photos. Used by the PhotoEditWidget. More...
#include <selectionInterface.h>
Public Slots | |
void | selectNone () |
selects none of the image More... | |
void | selectAll () |
selects all of the image More... | |
Signals | |
void | ctrlClick () |
emitted when a user CTRL-clicks a selection indicating the selection needs to be rotated intelligently More... | |
void | selectionChanged () |
emitted when the user changed the selected region More... | |
void | aspectRatioChanged () |
emitted when the user changed the aspect ratio of the selected region More... | |
void | lineSelected (QPoint p1, QPoint p2) |
emitted once line has been selected, on or the other points will be set to -1,-1 if the user escaped out the selected a line More... | |
Public Member Functions | |
SelectionInterface (QWidget *parent=0, const char *name=0) | |
Creates layout. More... | |
~SelectionInterface () | |
Deletes objects. More... | |
void | setPhoto (QString imageFilename, bool resetSelection=true) |
Updates displayed photo. More... | |
void | getSelection (QPoint &topLeft, QPoint &bottomRight) |
Returns the current selected coordinates (actual slideshow image space, aka not including buffered whitespace or widget offsets) More... | |
void | setSelection (QPoint topLeft, QPoint bottomRight, double cropMaxDimen=-1.0) |
Sets the current selection cropMaxDimen specifies the idealized dimension in dominant direction in inches (eg 7") More... | |
bool | selectionEmpty () |
returns true if selection is empty More... | |
void | getDisplaySize (int &width, int &height) |
returns the current photo display size (in screen pixels) More... | |
void | enterDrawLineMode () |
enter draw line mode - used for tilt correction More... | |
Protected Member Functions | |
QSize | sizeHint () |
void | paintEvent (QPaintEvent *e) |
void | mousePressEvent (QMouseEvent *e) |
void | mouseReleaseEvent (QMouseEvent *) |
void | mouseMoveEvent (QMouseEvent *e) |
void | resizeEvent (QResizeEvent *) |
void | keyPressEvent (QKeyEvent *e) |
void | keyReleaseEvent (QKeyEvent *e) |
Private Member Functions | |
DRAG_MODE | mouseActionByPosition (QPoint p) |
determine action based on mouse position More... | |
QPoint | cropSelectedPoint (QPoint p) |
crops a selected point to within the photo More... | |
QPoint | ConvertDisplayToImageCoordinate (QPoint p) |
converts a point from display coordinates to original image coordinates More... | |
QPoint | ConvertImageToDisplayCoordinate (QPoint p) |
converts a point from original image coordinates to display coordinates More... | |
void | constructDisplayImages () |
construct scaled image and unselected images for drawing purposes More... | |
void | updateCursorShape (QPoint p) |
update mouse cursor based on position over widget and selected region More... | |
bool | scaleSelection (int delta) |
increase/decrease selection while maintaining aspect ratio by changing selected width by delta More... | |
Private Attributes | |
QImage | fullScreenImage |
Full screen version of image. More... | |
QImage | scaledImage |
Scaled image used for display purposes. More... | |
QImage | unselectedScaledImage |
Grayscale version of scaled image, used for drawing non-selected regions. More... | |
QPoint | mousePressPoint |
first corner of selection, where mouse first clicked More... | |
QPoint | mouseDragPoint |
second corner of selection, where mouse moved to More... | |
QPoint | cachedMousePosition |
cached mouse position, used to scale or drag around selection area More... | |
DRAG_MODE | currentDragMode |
method of dragging out, either new selection or resizing selection corner or side More... | |
DRAG_MODE | currentMouseShape |
current mouse shape. More... | |
QString | origImageFilename |
original image filename More... | |
QSize | origImageSize |
original image dimensions More... | |
bool | SHIFT_Pressed |
state of SHIFT button, effects if mouse drags adjust or scale the current selection More... | |
bool | CTRL_Pressed |
state of CTRL button, effects if mouse clicks rotate current selection More... | |
QPoint | cachedSelctionCenter |
cache the aspect ratio when pressing the control buttion, this helps aleviate numerical error that builds up when scaling up and down selections More... | |
QSize | cachedSelectionSize |
double | cropMaxDimen |
Current crop max dimension (in inches) More... | |
Display widget for photos. Used by the PhotoEditWidget.
Definition at line 49 of file selectionInterface.h.
SelectionInterface::SelectionInterface | ( | QWidget * | parent = 0 , |
const char * | name = 0 |
||
) |
Creates layout.
Definition at line 51 of file selectionInterface.cpp.
References cachedMousePosition, cropMaxDimen, currentDragMode, currentMouseShape, mouseDragPoint, mousePressPoint, NO_EFFECT, selectAll(), and selectNone().
SelectionInterface::~SelectionInterface | ( | ) |
|
signal |
emitted when the user changed the aspect ratio of the selected region
Referenced by mouseMoveEvent(), mousePressEvent(), selectAll(), and selectNone().
|
private |
construct scaled image and unselected images for drawing purposes
Definition at line 127 of file selectionInterface.cpp.
References b, fullScreenImage, height, HSVtoRGB(), MAX, MIN, RGBtoHSV(), scaledImage, unselectedScaledImage, and width.
Referenced by resizeEvent(), and setPhoto().
|
private |
converts a point from display coordinates to original image coordinates
Definition at line 884 of file selectionInterface.cpp.
References height, origImageSize, scaledImage, and width.
Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
|
private |
converts a point from original image coordinates to display coordinates
Definition at line 910 of file selectionInterface.cpp.
References height, origImageSize, scaledImage, and width.
Referenced by enterDrawLineMode(), keyPressEvent(), keyReleaseEvent(), mouseActionByPosition(), mouseMoveEvent(), mouseReleaseEvent(), and paintEvent().
|
private |
crops a selected point to within the photo
Definition at line 936 of file selectionInterface.cpp.
References height, MAX, MIN, scaledImage, and width.
Referenced by mouseMoveEvent().
|
signal |
emitted when a user CTRL-clicks a selection indicating the selection needs to be rotated intelligently
Referenced by mousePressEvent().
void SelectionInterface::enterDrawLineMode | ( | ) |
enter draw line mode - used for tilt correction
Definition at line 1192 of file selectionInterface.cpp.
References cachedMousePosition, ConvertImageToDisplayCoordinate(), CTRL_Pressed, currentDragMode, DRAW_LINE, mouseDragPoint, mousePressPoint, SHIFT_Pressed, and updateCursorShape().
Referenced by EditingInterface::startCorrectTilt().
void SelectionInterface::getDisplaySize | ( | int & | width, |
int & | height | ||
) |
returns the current photo display size (in screen pixels)
Definition at line 1020 of file selectionInterface.cpp.
References scaledImage.
Referenced by EditingInterface::applyImageUpdate(), EditingInterface::revertCurrentPhoto(), EditingInterface::rotateFlip(), EditingInterface::setPhoto(), and EditingInterface::showNextPrevFirstLastPhoto().
void SelectionInterface::getSelection | ( | QPoint & | topLeft, |
QPoint & | bottomRight | ||
) |
Returns the current selected coordinates (actual slideshow image space, aka not including buffered whitespace or widget offsets)
Definition at line 1003 of file selectionInterface.cpp.
References MAX, MIN, mouseDragPoint, and mousePressPoint.
Referenced by EditingInterface::findSelection(), EditingInterface::rotateSelection(), and EditingInterface::selectAspectRatio().
|
protected |
Definition at line 1026 of file selectionInterface.cpp.
References bottomRight, cachedMousePosition, cachedSelctionCenter, ConvertImageToDisplayCoordinate(), CTRL_Pressed, currentDragMode, DRAW_LINE, lineSelected(), MAX, MIN, mouseDragPoint, mousePressPoint, NO_EFFECT, origImageSize, scaledImage, scaleSelection(), selectionChanged(), selectionEmpty(), selectNone(), SHIFT_Pressed, topLeft, and updateCursorShape().
|
protected |
Definition at line 1172 of file selectionInterface.cpp.
References cachedMousePosition, ConvertImageToDisplayCoordinate(), CTRL_Pressed, SHIFT_Pressed, and updateCursorShape().
|
signal |
emitted once line has been selected, on or the other points will be set to -1,-1 if the user escaped out the selected a line
Referenced by keyPressEvent(), and mouseReleaseEvent().
|
private |
determine action based on mouse position
Definition at line 361 of file selectionInterface.cpp.
References bottomRight, ConvertImageToDisplayCoordinate(), DRAG_THRESHOLD, DRAW_SELECTION, height, MAX, MIN, mouseDragPoint, mousePressPoint, MOVE_BOTTOM_LEFT_CORNER, MOVE_BOTTOM_RIGHT_CORNER, MOVE_BOTTOM_SIDE, MOVE_LEFT_SIDE, MOVE_RIGHT_SIDE, MOVE_SELECTION, MOVE_THRESHOLD, MOVE_TOP_LEFT_CORNER, MOVE_TOP_RIGHT_CORNER, MOVE_TOP_SIDE, NO_EFFECT, origImageSize, SCALE_SELECTION, scaledImage, SHIFT_Pressed, topLeft, and width.
Referenced by mouseMoveEvent(), mousePressEvent(), and updateCursorShape().
|
protected |
Definition at line 661 of file selectionInterface.cpp.
References aspectRatioChanged(), bottomRight, cachedMousePosition, cachedSelctionCenter, cachedSelectionSize, ConvertDisplayToImageCoordinate(), ConvertImageToDisplayCoordinate(), cropMaxDimen, cropSelectedPoint(), CTRL_Pressed, currentDragMode, currentMouseShape, DRAW_LINE, DRAW_SELECTION, MAX, MIN, mouseActionByPosition(), mouseDragPoint, mousePressPoint, MOVE_BOTTOM_LEFT_CORNER, MOVE_BOTTOM_RIGHT_CORNER, MOVE_BOTTOM_SIDE, MOVE_LEFT_SIDE, MOVE_RIGHT_SIDE, MOVE_SELECTION, MOVE_TOP_LEFT_CORNER, MOVE_TOP_RIGHT_CORNER, MOVE_TOP_SIDE, NO_EFFECT, origImageSize, scaleSelection(), selectionChanged(), SHIFT_Pressed, topLeft, and updateCursorShape().
|
protected |
Definition at line 446 of file selectionInterface.cpp.
References aspectRatioChanged(), bottomRight, ConvertDisplayToImageCoordinate(), cropMaxDimen, CTRL_Pressed, ctrlClick(), currentDragMode, DRAW_LINE, DRAW_SELECTION, MAX, MIN, mouseActionByPosition(), mouseDragPoint, mousePressPoint, MOVE_BOTTOM_LEFT_CORNER, MOVE_BOTTOM_RIGHT_CORNER, MOVE_BOTTOM_SIDE, MOVE_LEFT_SIDE, MOVE_RIGHT_SIDE, MOVE_SELECTION, MOVE_TOP_LEFT_CORNER, MOVE_TOP_RIGHT_CORNER, MOVE_TOP_SIDE, selectionChanged(), and topLeft.
|
protected |
Definition at line 834 of file selectionInterface.cpp.
References bottomRight, cachedMousePosition, ConvertDisplayToImageCoordinate(), ConvertImageToDisplayCoordinate(), currentDragMode, DRAW_LINE, lineSelected(), MAX, MIN, MINIMUM_SELECTION_SIZE, mouseDragPoint, mousePressPoint, NO_EFFECT, selectNone(), topLeft, and updateCursorShape().
|
protected |
Definition at line 171 of file selectionInterface.cpp.
References bottomRight, buffer, ConvertImageToDisplayCoordinate(), cropMaxDimen, currentDragMode, DRAW_LINE, height, MAX, MIN, mouseDragPoint, mousePressPoint, NO_EFFECT, scaledImage, TEXT_MARGIN, topLeft, unselectedScaledImage, and width.
|
protected |
Definition at line 118 of file selectionInterface.cpp.
References constructDisplayImages(), and fullScreenImage.
|
private |
increase/decrease selection while maintaining aspect ratio by changing selected width by delta
Definition at line 575 of file selectionInterface.cpp.
References bottomRight, cachedSelctionCenter, cachedSelectionSize, MAX, MIN, mouseDragPoint, mousePressPoint, origImageSize, and topLeft.
Referenced by keyPressEvent(), and mouseMoveEvent().
|
slot |
selects all of the image
Definition at line 956 of file selectionInterface.cpp.
References aspectRatioChanged(), cachedSelctionCenter, cachedSelectionSize, cropMaxDimen, mouseDragPoint, mousePressPoint, origImageSize, and selectionChanged().
Referenced by SelectionInterface().
|
signal |
emitted when the user changed the selected region
Referenced by keyPressEvent(), mouseMoveEvent(), mousePressEvent(), selectAll(), selectNone(), setPhoto(), and setSelection().
bool SelectionInterface::selectionEmpty | ( | ) |
returns true if selection is empty
Definition at line 947 of file selectionInterface.cpp.
References mouseDragPoint, and mousePressPoint.
Referenced by keyPressEvent().
|
slot |
selects none of the image
Definition at line 975 of file selectionInterface.cpp.
References aspectRatioChanged(), cropMaxDimen, mouseDragPoint, mousePressPoint, and selectionChanged().
Referenced by EditingInterface::applyImageUpdate(), keyPressEvent(), mouseReleaseEvent(), and SelectionInterface().
void SelectionInterface::setPhoto | ( | QString | imageFilename, |
bool | resetSelection = true |
||
) |
Updates displayed photo.
Definition at line 85 of file selectionInterface.cpp.
References constructDisplayImages(), cropMaxDimen, CTRL_Pressed, fullScreenImage, getImageSize(), mouseDragPoint, mousePressPoint, origImageFilename, origImageSize, scaleImage(), selectionChanged(), and SHIFT_Pressed.
Referenced by EditingInterface::applyImageUpdate(), EditingInterface::revertCurrentPhoto(), EditingInterface::rotateFlip(), EditingInterface::setPhoto(), and EditingInterface::showNextPrevFirstLastPhoto().
void SelectionInterface::setSelection | ( | QPoint | topLeft, |
QPoint | bottomRight, | ||
double | cropMaxDimen = -1.0 |
||
) |
Sets the current selection cropMaxDimen specifies the idealized dimension in dominant direction in inches (eg 7")
Definition at line 985 of file selectionInterface.cpp.
References bottomRight, cachedSelctionCenter, cachedSelectionSize, cropMaxDimen, mouseDragPoint, mousePressPoint, selectionChanged(), and topLeft.
Referenced by EditingInterface::rotateSelection(), EditingInterface::selectAspectRatio(), and EditingInterface::showNextPrevFirstLastPhoto().
|
protected |
|
private |
update mouse cursor based on position over widget and selected region
Definition at line 525 of file selectionInterface.cpp.
References CROSS_CURSOR, CTRL_Pressed, currentDragMode, currentMouseShape, DRAW_LINE, DRAW_SELECTION, getCursor(), mouseActionByPosition(), MOVE_BOTTOM_LEFT_CORNER, MOVE_BOTTOM_RIGHT_CORNER, MOVE_BOTTOM_SIDE, MOVE_HOR_CURSOR, MOVE_LEFT_SIDE, MOVE_RIGHT_SIDE, MOVE_SELECTION, MOVE_SELECTION_CURSOR, MOVE_TL_CURSOR, MOVE_TOP_LEFT_CORNER, MOVE_TOP_RIGHT_CORNER, MOVE_TOP_SIDE, MOVE_TR_CURSOR, MOVE_VERT_CURSOR, ROTATE_CURSOR, SCALE_SELECTION_CURSOR, SHIFT_Pressed, and TARGET_CURSOR.
Referenced by enterDrawLineMode(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), and mouseReleaseEvent().
|
private |
cached mouse position, used to scale or drag around selection area
Definition at line 151 of file selectionInterface.h.
Referenced by enterDrawLineMode(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mouseReleaseEvent(), and SelectionInterface().
|
private |
cache the aspect ratio when pressing the control buttion, this helps aleviate numerical error that builds up when scaling up and down selections
Definition at line 174 of file selectionInterface.h.
Referenced by keyPressEvent(), mouseMoveEvent(), scaleSelection(), selectAll(), and setSelection().
|
private |
Definition at line 175 of file selectionInterface.h.
Referenced by mouseMoveEvent(), scaleSelection(), selectAll(), and setSelection().
|
private |
Current crop max dimension (in inches)
Definition at line 178 of file selectionInterface.h.
Referenced by mouseMoveEvent(), mousePressEvent(), paintEvent(), selectAll(), SelectionInterface(), selectNone(), setPhoto(), and setSelection().
|
private |
state of CTRL button, effects if mouse clicks rotate current selection
Definition at line 170 of file selectionInterface.h.
Referenced by enterDrawLineMode(), keyPressEvent(), keyReleaseEvent(), mouseMoveEvent(), mousePressEvent(), setPhoto(), and updateCursorShape().
|
private |
method of dragging out, either new selection or resizing selection corner or side
Definition at line 154 of file selectionInterface.h.
Referenced by enterDrawLineMode(), keyPressEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), SelectionInterface(), and updateCursorShape().
|
private |
current mouse shape.
by caching this value we avoid resetting the mouse cursor every time it moves etc.
Definition at line 158 of file selectionInterface.h.
Referenced by mouseMoveEvent(), SelectionInterface(), and updateCursorShape().
|
private |
Full screen version of image.
Definition at line 136 of file selectionInterface.h.
Referenced by constructDisplayImages(), resizeEvent(), and setPhoto().
|
private |
second corner of selection, where mouse moved to
Definition at line 148 of file selectionInterface.h.
Referenced by enterDrawLineMode(), getSelection(), keyPressEvent(), mouseActionByPosition(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), scaleSelection(), selectAll(), selectionEmpty(), SelectionInterface(), selectNone(), setPhoto(), and setSelection().
|
private |
first corner of selection, where mouse first clicked
Definition at line 145 of file selectionInterface.h.
Referenced by enterDrawLineMode(), getSelection(), keyPressEvent(), mouseActionByPosition(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), scaleSelection(), selectAll(), selectionEmpty(), SelectionInterface(), selectNone(), setPhoto(), and setSelection().
|
private |
original image filename
Definition at line 161 of file selectionInterface.h.
Referenced by setPhoto().
|
private |
original image dimensions
Definition at line 164 of file selectionInterface.h.
Referenced by ConvertDisplayToImageCoordinate(), ConvertImageToDisplayCoordinate(), keyPressEvent(), mouseActionByPosition(), mouseMoveEvent(), scaleSelection(), selectAll(), and setPhoto().
|
private |
Scaled image used for display purposes.
Definition at line 139 of file selectionInterface.h.
Referenced by constructDisplayImages(), ConvertDisplayToImageCoordinate(), ConvertImageToDisplayCoordinate(), cropSelectedPoint(), getDisplaySize(), keyPressEvent(), mouseActionByPosition(), and paintEvent().
|
private |
state of SHIFT button, effects if mouse drags adjust or scale the current selection
Definition at line 167 of file selectionInterface.h.
Referenced by enterDrawLineMode(), keyPressEvent(), keyReleaseEvent(), mouseActionByPosition(), mouseMoveEvent(), setPhoto(), and updateCursorShape().
|
private |
Grayscale version of scaled image, used for drawing non-selected regions.
Definition at line 142 of file selectionInterface.h.
Referenced by constructDisplayImages(), and paintEvent().