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 );
PREVIEW_MOUSE_MODE mouseMode
current mouse move mode
SplitViewInterface(QWidget *parent=0, const char *name=0)
Creates layout.
PREVIEW_MODE previewMode
Current display setting (adjusted or split screen)
QImage & getOrigImage()
returns orig image object
double displayToWorld(int coordinate)
convert display coordinates to world coordinates (double from 0.0 - 1.0)
bool nearSplitPoint(QPoint p)
determines if mouse is near split point
QString originalString
Original and adjusted strings.
QImage adjustedImage
Scaled adjusted image.
void setImages(QImage origImage, QImage adjustedImage)
const QCursor & getCursor(CUSTOM_CURSOR_TYPE type)
virtual QSize minimumSizeHint() const
void mouseReleaseEvent(QMouseEvent *)
void mouseMoveEvent(QMouseEvent *e)
double dragOffset
x (or y) coordinate of split between drawn adjusted and original images
bool forceDrawLabel
Draw original/adjusted lables outside of split view mode?
void setPreviewMode(PREVIEW_MODE mode, bool forceDrawLabel=false)
Sets preview mode.
PREVIEW_MODE
current preview mode
#define TEXT_BACKGROUND_MARGIN
int worldToDisplay(double coordinate)
convert world coordinates to display coordinates (int from 0 to origImage width-1) ...
QImage origImage
Scaled original image.
void mousePressEvent(QMouseEvent *e)
void paintEvent(QPaintEvent *e)
void setAdjustedImage(QImage adjustedImage)
sets adjusted image and repaints
QFont textFont
Larger font used for drawing text.
PREVIEW_MOUSE_MODE currentMouseShape
current mouse shape.