AlbumShaper
1.0a3
|
#include <panningPreviewInterface.h>
Public Slots | |
void | setSelection (QRect selection) |
Signals | |
void | selectionChanged () |
Public Member Functions | |
PanningPreviewInterface (QString imageFilename, QWidget *parent=0, const char *name=0) | |
Creates layout. | |
virtual QSize | sizeHint () const |
QRect | getSelection () |
QSize | paintingSize () |
Protected Member Functions | |
void | resizeEvent (QResizeEvent *) |
Private Member Functions | |
void | generateOrigImage () |
Private Attributes | |
QImage | fullSizeImage |
Full size image. | |
QRect | selection |
Current selection. |
Definition at line 21 of file panningPreviewInterface.h.
PanningPreviewInterface::PanningPreviewInterface | ( | QString | imageFilename, |
QWidget * | parent = 0 , |
||
const char * | name = 0 |
||
) |
Creates layout.
Definition at line 15 of file panningPreviewInterface.cpp.
References fullSizeImage, and selection.
: SplitViewInterface (parent, name ) { //load full size image fullSizeImage = QImage( imageFilename ); //a 0-width selection is invalid and prevents //resize events from triggering painting //until the true selection region is set selection.setWidth( 0 ); }
void PanningPreviewInterface::generateOrigImage | ( | ) | [private] |
Definition at line 105 of file panningPreviewInterface.cpp.
References fullSizeImage, selection, selectionChanged(), and SplitViewInterface::setImages().
Referenced by setSelection().
{ //generate orig image //set adjusted image to null so repain won't occur until it is reset setImages( fullSizeImage.copy( selection.left(), selection.top(), selection.width(), selection.height() ), QImage() ); //emit signal indicating adjusted image is out of date emit selectionChanged(); }
QRect PanningPreviewInterface::getSelection | ( | ) |
Definition at line 117 of file panningPreviewInterface.cpp.
References selection.
Referenced by GrainEditor::generateAdjustedPreviewImage(), and GrainEditor::previewResized().
{ return selection; }
QSize PanningPreviewInterface::paintingSize | ( | ) |
Definition at line 34 of file panningPreviewInterface.cpp.
References fullSizeImage.
Referenced by resizeEvent(), and setSelection().
{ return QSize( QMIN( fullSizeImage.width(), size().width() ), QMIN( fullSizeImage.height(), size().height() ) ); }
void PanningPreviewInterface::resizeEvent | ( | QResizeEvent * | ) | [protected, virtual] |
Implements SplitViewInterface.
Definition at line 40 of file panningPreviewInterface.cpp.
References fullSizeImage, paintingSize(), selection, and setSelection().
{ //center of new selection... QPoint center; //if selection not set then default to center of image if( selection.width() == 0) { //compute center selection center center = QPoint( fullSizeImage.width() / 2, fullSizeImage.height() / 2 ); } //else construct new selection that is centered over old selection else { //compute center selection center center = QPoint( selection.left() + selection.width()/2, selection.top() + selection.height()/2 ); } //determine width/height that will be used for painting QSize actualSize = paintingSize(); //compute new selection area centerd over old selection region QRect newSelection; newSelection.setLeft( center.x() - actualSize.width() /2 ); newSelection.setTop ( center.y() - actualSize.height()/2 ); newSelection.setRight( newSelection.left() + actualSize.width() - 1 ); newSelection.setBottom( newSelection.top() + actualSize.height() - 1 ); //set selection which will result in regenerating of orig and adjusted images setSelection( newSelection ); }
void PanningPreviewInterface::selectionChanged | ( | ) | [signal] |
Referenced by generateOrigImage().
void PanningPreviewInterface::setSelection | ( | QRect | selection | ) | [slot] |
Definition at line 74 of file panningPreviewInterface.cpp.
References fullSizeImage, generateOrigImage(), paintingSize(), and selection.
Referenced by resizeEvent().
{ //set the selection selection = s; //get the available painting size QSize actualSize = paintingSize(); //if too wide or tall shrink selection if( selection.width() > actualSize.width() ) selection.setRight( selection.left() + actualSize.width() - 1 ); if( selection.height() > actualSize.height() ) selection.setBottom( selection.top() + actualSize.height() - 1 ); //shift selection area if it extends beyond image boundary if( selection.left() < 0 ) selection.moveBy( -selection.left(), 0 ); if( selection.top() < 0 ) selection.moveBy( 0, -selection.top() ); if( selection.right() > fullSizeImage.width()-1 ) selection.moveBy( (fullSizeImage.width()-1) - selection.right(), 0 ); if( selection.bottom() > fullSizeImage.height()-1 ) selection.moveBy( 0, (fullSizeImage.height()-1) - selection.bottom() ); //regenerate orig and adjusted images generateOrigImage(); }
QSize PanningPreviewInterface::sizeHint | ( | ) | const [virtual] |
Implements SplitViewInterface.
Definition at line 28 of file panningPreviewInterface.cpp.
{ //subjetively chosen default size :) return QSize( 500, 400 ); }
QImage PanningPreviewInterface::fullSizeImage [private] |
Full size image.
Definition at line 46 of file panningPreviewInterface.h.
Referenced by generateOrigImage(), paintingSize(), PanningPreviewInterface(), resizeEvent(), and setSelection().
QRect PanningPreviewInterface::selection [private] |
Current selection.
Definition at line 49 of file panningPreviewInterface.h.
Referenced by generateOrigImage(), getSelection(), PanningPreviewInterface(), resizeEvent(), and setSelection().