12#include <qapplication.h>
20#define MIN(x,y) ((x) < (y) ? (x) : (y))
21#define MAX(x,y) ((x) > (y) ? (x) : (y))
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 );
132 displayRect.left(), displayRect.top(),
133 displayRect.width(), displayRect.height() );
141 pen.setColor( Qt::gray );
142 pen.setStyle( Qt::SolidLine );
144 bufferPainter.setPen( pen);
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...
void recenterSelection(QPoint mousePosition)
util function used to center selection about mouse location
QImage unselectedScaledImage
Unselected scaled image (desaturated version of scaled image)
void mouseMoveEvent(QMouseEvent *e)
~SelectionPlacementInterface()
Deletes objects.
void mouseReleaseEvent(QMouseEvent *)
QRect getSelectedRegion()
Returns the selected region in image space.
bool overRegion(QPoint p)
util function used to determine if mouse is over selected region
QRect imageToDisplay(QRect r)
convert rectangle from image coordinates to display coordinates
virtual QSize sizeHint() const
void mousePressEvent(QMouseEvent *e)
bool currentMouseShapeIsDrag
current mouse shape.
void paintEvent(QPaintEvent *e)
QSize origImageSize
original image dimensions
virtual QSize minimumSizeHint() const
QImage scaledImage
Scaled image used for display purposes.
SelectionPlacementInterface(QString imageFilename, QWidget *parent=0, const char *name=0)
Creates layout.
void setSelectedRegion(QRect selection)
Set the select region using image space coordinates.
void placementChanged(QRect)
const QCursor & getCursor(CUSTOM_CURSOR_TYPE type)