16 #include <QMouseEvent>
17 #include <QPaintEvent>
21 #include "../cursors.h"
22 #include "../../backend/tools/imageTools.h"
24 #define TEXT_BACKGROUND_MARGIN 2
28 #define DRAG_THRESHOLD 8
56 setMouseTracking(
true);
59 setFocusPolicy( Qt::ClickFocus );
78 QPainter bufferPainter( &
buffer );
81 bufferPainter.setClipping(
false);
84 bufferPainter.fillRect(
buffer.rect(), backgroundBrush() );
88 pen.setStyle( Qt::SolidLine );
89 pen.setColor( Qt::white );
91 bufferPainter.setPen( pen);
103 bufferPainter.drawImage( QPoint(xOffset, yOffset),
adjustedImage );
115 QBrush(Qt::darkGray) );
116 bufferPainter.drawText( x, y,
123 bufferPainter.drawImage( QPoint(xOffset, yOffset),
origImage );
135 QBrush(Qt::darkGray) );
136 bufferPainter.drawText( x, y,
145 QString label1, label2;
161 bufferPainter.drawImage( QPoint(xOffset, yOffset),
origImage );
169 bufferPainter.drawImage( xOffset + halfWay,
178 bufferPainter.drawImage( xOffset,
188 bufferPainter.drawLine( xOffset + halfWay,
194 int x = xOffset + (halfWay-fm.width(label1))/2;
201 QBrush(Qt::darkGray) );
202 bufferPainter.drawText( x, y,
206 x = xOffset + halfWay + (
origImage.width() - halfWay - fm.width(label2))/2;
212 QBrush(Qt::darkGray) );
213 bufferPainter.drawText( x, y,
222 bufferPainter.drawImage( xOffset,
231 bufferPainter.drawImage( xOffset,
240 bufferPainter.drawLine( xOffset,
246 int x = xOffset + (
origImage.width()-fm.width(label1))/2;
253 QBrush(Qt::darkGray) );
254 bufferPainter.drawText( x, y,
258 x = xOffset + (
origImage.width()-fm.width(label2))/2;
259 y = yOffset + halfWay + fm.height();
265 QBrush(Qt::darkGray) );
266 bufferPainter.drawText( x, y,
277 e->rect().x(), e->rect().y(),
279 e->rect().x(), e->rect().y(),
280 e->rect().width(), e->rect().height() );
334 setCursor( Qt::ArrowCursor );
360 mousePos = e->pos().x();
362 mousePos = QMIN( mousePos, paintingOffset +
origImage.width() -
368 mousePos = e->pos().y();
370 mousePos = QMIN( mousePos, paintingOffset +
origImage.height() -
388 setCursor( Qt::ArrowCursor );
395 {
return ((
double) (coordinate+1))/
origImage.width(); }
397 {
return ((
double) (coordinate+1))/
origImage.height(); }
403 {
return (
int) (coordinate*(
origImage.width() -1) ); }
405 {
return (
int) (coordinate*(
origImage.height()-1) ); }
413 return QSize( w, h );
420 QImage adjustedImage )
PREVIEW_MOUSE_MODE mouseMode
current mouse move mode
int worldToDisplay(double coordinate)
convert world coordinates to display coordinates (int from 0 to origImage width-1)
virtual QSize minimumSizeHint() const
bool nearSplitPoint(QPoint p)
determines if mouse is near split point
QString originalString
Original and adjusted strings.
double displayToWorld(int coordinate)
convert display coordinates to world coordinates (double from 0.0 - 1.0)
void mousePressEvent(QMouseEvent *e)
bool forceDrawLabel
Draw original/adjusted lables outside of split view mode?
QImage adjustedImage
Scaled adjusted image.
void paintEvent(QPaintEvent *e)
double dragOffset
x (or y) coordinate of split between drawn adjusted and original images
QFont textFont
Larger font used for drawing text.
QImage & getOrigImage()
returns orig image object
void setImages(QImage origImage, QImage adjustedImage)
QImage origImage
Scaled original image.
PREVIEW_MODE previewMode
Current display setting (adjusted or split screen)
SplitViewInterface(QWidget *parent=0, const char *name=0)
Creates layout.
void mouseReleaseEvent(QMouseEvent *)
void mouseMoveEvent(QMouseEvent *e)
void setAdjustedImage(QImage adjustedImage)
sets adjusted image and repaints
PREVIEW_MOUSE_MODE currentMouseShape
current mouse shape.
void setPreviewMode(PREVIEW_MODE mode, bool forceDrawLabel=false)
Sets preview mode.
const QCursor & getCursor(CUSTOM_CURSOR_TYPE type)
#define TEXT_BACKGROUND_MARGIN
PREVIEW_MODE
current preview mode