AlbumShaper  1.0a3
Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
PanningPreviewInterface Class Reference

#include <panningPreviewInterface.h>

Inheritance diagram for PanningPreviewInterface:
Inheritance graph
[legend]
Collaboration diagram for PanningPreviewInterface:
Collaboration graph
[legend]

Public Slots

void setSelection (QRect selection)
 

Signals

void selectionChanged ()
 

Public Member Functions

 PanningPreviewInterface (QString imageFilename, QWidget *parent=0, const char *name=0)
 Creates layout. More...
 
virtual QSize sizeHint () const
 
QRect getSelection ()
 
QSize paintingSize ()
 
- Public Member Functions inherited from SplitViewInterface
 SplitViewInterface (QWidget *parent=0, const char *name=0)
 Creates layout. More...
 
void setPreviewMode (PREVIEW_MODE mode, bool forceDrawLabel=false)
 Sets preview mode. More...
 
virtual QSize minimumSizeHint () const
 
void setImages (QImage origImage, QImage adjustedImage)
 
void setAdjustedImage (QImage adjustedImage)
 sets adjusted image and repaints More...
 
QImage & getOrigImage ()
 returns orig image object More...
 

Protected Member Functions

void resizeEvent (QResizeEvent *)
 
- Protected Member Functions inherited from SplitViewInterface
void paintEvent (QPaintEvent *e)
 
void mousePressEvent (QMouseEvent *e)
 
void mouseReleaseEvent (QMouseEvent *)
 
void mouseMoveEvent (QMouseEvent *e)
 

Private Member Functions

void generateOrigImage ()
 

Private Attributes

QImage fullSizeImage
 Full size image. More...
 
QRect selection
 Current selection. More...
 

Detailed Description

Definition at line 23 of file panningPreviewInterface.h.

Constructor & Destructor Documentation

§ PanningPreviewInterface()

PanningPreviewInterface::PanningPreviewInterface ( QString  imageFilename,
QWidget parent = 0,
const char *  name = 0 
)

Creates layout.

Definition at line 17 of file panningPreviewInterface.cpp.

References fullSizeImage, and selection.

18  :
19  SplitViewInterface (parent, name )
20 {
21  //load full size image
22  fullSizeImage = QImage( imageFilename );
23 
24  //a 0-width selection is invalid and prevents
25  //resize events from triggering painting
26  //until the true selection region is set
27  selection.setWidth( 0 );
28 }
QRect selection
Current selection.
SplitViewInterface(QWidget *parent=0, const char *name=0)
Creates layout.
QImage fullSizeImage
Full size image.

Member Function Documentation

§ generateOrigImage()

void PanningPreviewInterface::generateOrigImage ( )
private

Definition at line 107 of file panningPreviewInterface.cpp.

References fullSizeImage, selection, selectionChanged(), and SplitViewInterface::setImages().

Referenced by setSelection().

108 {
109  //generate orig image
110  //set adjusted image to null so repain won't occur until it is reset
111  setImages( fullSizeImage.copy( selection.left(), selection.top(),
112  selection.width(), selection.height() ),
113  QImage() );
114 
115  //emit signal indicating adjusted image is out of date
116  emit selectionChanged();
117 }
QRect selection
Current selection.
void setImages(QImage origImage, QImage adjustedImage)
QImage fullSizeImage
Full size image.

§ getSelection()

QRect PanningPreviewInterface::getSelection ( )

Definition at line 119 of file panningPreviewInterface.cpp.

References selection.

Referenced by GrainEditor::generateAdjustedPreviewImage(), and GrainEditor::previewResized().

120 { return selection; }
QRect selection
Current selection.

§ paintingSize()

QSize PanningPreviewInterface::paintingSize ( )

Definition at line 36 of file panningPreviewInterface.cpp.

References fullSizeImage.

Referenced by resizeEvent(), and setSelection().

37 {
38  return QSize( QMIN( fullSizeImage.width(), size().width() ),
39  QMIN( fullSizeImage.height(), size().height() ) );
40 }
QImage fullSizeImage
Full size image.

§ resizeEvent()

void PanningPreviewInterface::resizeEvent ( QResizeEvent *  )
protectedvirtual

Implements SplitViewInterface.

Definition at line 42 of file panningPreviewInterface.cpp.

References fullSizeImage, paintingSize(), selection, and setSelection().

43 {
44  //center of new selection...
45  QPoint center;
46 
47  //if selection not set then default to center of image
48  if( selection.width() == 0)
49  {
50  //compute center selection center
51  center = QPoint( fullSizeImage.width() / 2,
52  fullSizeImage.height() / 2 );
53  }
54  //else construct new selection that is centered over old selection
55  else
56  {
57  //compute center selection center
58  center = QPoint( selection.left() + selection.width()/2,
59  selection.top() + selection.height()/2 );
60  }
61 
62  //determine width/height that will be used for painting
63  QSize actualSize = paintingSize();
64 
65  //compute new selection area centerd over old selection region
66  QRect newSelection;
67  newSelection.setLeft( center.x() - actualSize.width() /2 );
68  newSelection.setTop ( center.y() - actualSize.height()/2 );
69  newSelection.setRight( newSelection.left() + actualSize.width() - 1 );
70  newSelection.setBottom( newSelection.top() + actualSize.height() - 1 );
71 
72  //set selection which will result in regenerating of orig and adjusted images
73  setSelection( newSelection );
74 }
QRect selection
Current selection.
void setSelection(QRect selection)
QImage fullSizeImage
Full size image.

§ selectionChanged

void PanningPreviewInterface::selectionChanged ( )
signal

Referenced by generateOrigImage().

§ setSelection

void PanningPreviewInterface::setSelection ( QRect  selection)
slot

Definition at line 76 of file panningPreviewInterface.cpp.

References fullSizeImage, generateOrigImage(), paintingSize(), and selection.

Referenced by resizeEvent().

77 {
78  //set the selection
79  selection = s;
80 
81  //get the available painting size
82  QSize actualSize = paintingSize();
83 
84  //if too wide or tall shrink selection
85  if( selection.width() > actualSize.width() )
86  selection.setRight( selection.left() + actualSize.width() - 1 );
87  if( selection.height() > actualSize.height() )
88  selection.setBottom( selection.top() + actualSize.height() - 1 );
89 
90  //shift selection area if it extends beyond image boundary
91  if( selection.left() < 0 )
92  selection.moveBy( -selection.left(), 0 );
93 
94  if( selection.top() < 0 )
95  selection.moveBy( 0, -selection.top() );
96 
97  if( selection.right() > fullSizeImage.width()-1 )
98  selection.moveBy( (fullSizeImage.width()-1) - selection.right(), 0 );
99 
100  if( selection.bottom() > fullSizeImage.height()-1 )
101  selection.moveBy( 0, (fullSizeImage.height()-1) - selection.bottom() );
102 
103  //regenerate orig and adjusted images
105 }
QRect selection
Current selection.
QImage fullSizeImage
Full size image.

§ sizeHint()

QSize PanningPreviewInterface::sizeHint ( ) const
virtual

Implements SplitViewInterface.

Definition at line 30 of file panningPreviewInterface.cpp.

31 {
32  //subjetively chosen default size :)
33  return QSize( 500, 400 );
34 }

Member Data Documentation

§ fullSizeImage

QImage PanningPreviewInterface::fullSizeImage
private

Full size image.

Definition at line 48 of file panningPreviewInterface.h.

Referenced by generateOrigImage(), paintingSize(), PanningPreviewInterface(), resizeEvent(), and setSelection().

§ selection

QRect PanningPreviewInterface::selection
private

Current selection.

Definition at line 51 of file panningPreviewInterface.h.

Referenced by generateOrigImage(), getSelection(), PanningPreviewInterface(), resizeEvent(), and setSelection().


The documentation for this class was generated from the following files: