12 #include <qapplication.h> 17 #include <QMouseEvent> 18 #include <QPaintEvent> 20 #define MIN(x,y) ((x) < (y) ? (x) : (y)) 21 #define MAX(x,y) ((x) > (y) ? (x) : (y)) 25 #include "../../backend/tools/imageTools.h" 26 #include "../cursors.h" 30 QWidget *parent,
const char* name )
51 rgb = ((QRgb*)scanLine+x);
53 double r = ((double)qRed(*rgb) )/255.0;
54 double g = ((double)qGreen(*rgb) )/255.0;
55 double b = ((double)qBlue(*rgb) )/255.0;
66 int rp = (int)
MIN(
MAX((r*255), 0), 255 );
67 int gp = (int)
MIN(
MAX((g*255), 0), 255 );
68 int bp = (int)
MIN(
MAX((b*255), 0), 255 );
71 *rgb = qRgb(rp,gp,bp);
77 setMouseTracking(
true);
84 setFocusPolicy( Qt::ClickFocus );
88 selection.setBottomRight( QPoint( -1, -1 ) );
102 QPainter bufferPainter( &buffer );
105 bufferPainter.setClipping(
false);
108 bufferPainter.fillRect( buffer.rect(), backgroundBrush() );
116 bufferPainter.drawImage( QPoint(xOffset, yOffset),
scaledImage );
126 QPoint
topLeft = displayRect.topLeft() + QPoint( xOffset, yOffset );
127 QPoint
bottomRight = displayRect.bottomRight() + QPoint( xOffset, yOffset );
130 bufferPainter.drawImage( topLeft.x(), topLeft.y(),
132 displayRect.left(), displayRect.top(),
133 displayRect.width(), displayRect.height() );
141 pen.setColor( Qt::gray );
142 pen.setStyle( Qt::SolidLine );
144 bufferPainter.setPen( pen);
146 QRect selctRect( topLeft, bottomRight );
147 bufferPainter.drawRect(selctRect);
156 e->rect().x(), e->rect().y(),
158 e->rect().x(), e->rect().y(),
159 e->rect().width(), e->rect().height() );
186 return ( p.x() >= xOffset + displayRect.left() &&
187 p.x() <= xOffset + displayRect.right() &&
188 p.y() >= yOffset + displayRect.top() &&
189 p.y() <= yOffset + displayRect.bottom() );
195 QPoint center = QPoint( ((
origImageSize.width()-1) * mousePosition.x()) / (
width()-1),
245 setCursor( Qt::ArrowCursor );
279 { res.moveBy( (
scaledImage.width()-1) - res.right(), 0 ); }
282 { res.moveBy( 0, (
scaledImage.height()-1) - res.bottom() ); }
bool currentlyDragging
dragging the mouse only moves the selection if the mouse button is pressed first over the selected re...
QRect getSelectedRegion()
Returns the selected region in image space.
void mouseReleaseEvent(QMouseEvent *)
void recenterSelection(QPoint mousePosition)
util function used to center selection about mouse location
QRect imageToDisplay(QRect r)
convert rectangle from image coordinates to display coordinates
QSize origImageSize
original image dimensions
virtual QSize sizeHint() const
QImage unselectedScaledImage
Unselected scaled image (desaturated version of scaled image)
void mouseMoveEvent(QMouseEvent *e)
~SelectionPlacementInterface()
Deletes objects.
void setSelectedRegion(QRect selection)
Set the select region using image space coordinates.
void mousePressEvent(QMouseEvent *e)
virtual QSize minimumSizeHint() const
bool currentMouseShapeIsDrag
current mouse shape.
const QCursor & getCursor(CUSTOM_CURSOR_TYPE type)
QImage scaledImage
Scaled image used for display purposes.
bool overRegion(QPoint p)
util function used to determine if mouse is over selected region
SelectionPlacementInterface(QString imageFilename, QWidget *parent=0, const char *name=0)
Creates layout.
void placementChanged(QRect)
void paintEvent(QPaintEvent *e)