00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
#ifndef GUI_EDITING_SELECTIONINTERFACE_H
00012
#define GUI_EDITING_SELECTIONINTERFACE_H
00013
00015 typedef enum
00016 {
00017
DRAW_SELECTION,
00018
MOVE_SELECTION,
00019
MOVE_TOP_LEFT_CORNER,
00020
MOVE_TOP_RIGHT_CORNER,
00021
MOVE_BOTTOM_LEFT_CORNER,
00022
MOVE_BOTTOM_RIGHT_CORNER,
00023
MOVE_LEFT_SIDE,
00024
MOVE_RIGHT_SIDE,
00025
MOVE_TOP_SIDE,
00026
MOVE_BOTTOM_SIDE,
00027
SCALE_SELECTION,
00028
DRAW_LINE,
00029
NO_EFFECT
00030 }
DRAG_MODE;
00031
00032
00033
00034
class QPoint;
00035
00036
00037
#include <qwidget.h>
00038
#include <qimage.h>
00039
00040
00043
00044 class SelectionInterface :
public QWidget
00045 {
00046 Q_OBJECT
00047
00048
public:
00050
SelectionInterface(
QWidget *parent=0,
00051
const char* name=0);
00052
00054
~SelectionInterface();
00055
00057
void setPhoto(QString imageFilename,
bool resetSelection=
true);
00058
00061
void getSelection(QPoint &
topLeft, QPoint &
bottomRight);
00062
00065
void setSelection(QPoint
topLeft, QPoint
bottomRight,
double cropMaxDimen=-1.0);
00066
00068
bool selectionEmpty();
00069
00071
void getDisplaySize(
int &
width,
int &
height);
00072
00074
void enterDrawLineMode();
00075
00076 signals:
00079
void ctrlClick();
00080
00082
void selectionChanged();
00083
00085
void aspectRatioChanged();
00086
00089
void lineSelected( QPoint p1, QPoint p2 );
00090
00091
protected:
00092 QSize
sizeHint();
00093
void paintEvent( QPaintEvent *e);
00094
void mousePressEvent( QMouseEvent *e);
00095
void mouseReleaseEvent( QMouseEvent *);
00096
void mouseMoveEvent( QMouseEvent *e);
00097
void resizeEvent( QResizeEvent * );
00098
void keyPressEvent(QKeyEvent *e);
00099
void keyReleaseEvent(QKeyEvent *e);
00100
00101
public slots:
00103
void selectNone();
00104
00106
void selectAll();
00107
00108
private:
00110
DRAG_MODE mouseActionByPosition(QPoint p);
00111
00113 QPoint
cropSelectedPoint(QPoint p);
00114
00116 QPoint
ConvertDisplayToImageCoordinate( QPoint p );
00117
00119 QPoint
ConvertImageToDisplayCoordinate( QPoint p );
00120
00122
void constructDisplayImages();
00123
00125
void updateCursorShape( QPoint p );
00126
00128
bool scaleSelection(
int delta );
00129
00131 QImage
fullScreenImage;
00132
00134 QImage
scaledImage;
00135
00137 QImage
unselectedScaledImage;
00138
00140 QPoint
mousePressPoint;
00141
00143 QPoint
mouseDragPoint;
00144
00146 QPoint
cachedMousePosition;
00147
00149 DRAG_MODE currentDragMode;
00150
00153 DRAG_MODE currentMouseShape;
00154
00156 QString
origImageFilename;
00157
00159 QSize
origImageSize;
00160
00162 bool SHIFT_Pressed;
00163
00165 bool CTRL_Pressed;
00166
00169 QPoint
cachedSelctionCenter;
00170 QSize
cachedSelectionSize;
00171
00173 double cropMaxDimen;
00174
00175 };
00176
00177
00178
#endif //GUI_EDITING_SELECTIONINTERFACE_H