ZImageView Class Reference

#include <zimageview.h>

Inheritance diagram for ZImageView:

TorMapWidget List of all members.

Public Slots

void resetZoomPoint ()
void zoom (float pct)
void zoom (QPoint zoomAt, float pct)
void zoomIn ()
void zoomOut ()

Public Member Functions

 ZImageView (QWidget *parent=0)
void setImage (QImage &pixmap)

Protected Member Functions

virtual void paintImage (QPainter *painter)
virtual void paintEvent (QPaintEvent *)
virtual void mousePressEvent (QMouseEvent *e)
virtual void mouseReleaseEvent (QMouseEvent *e)
virtual void mouseMoveEvent (QMouseEvent *e)
virtual void resizeEvent (QResizeEvent *e)
QPair< QRect, QRect > updateViewport (int screendx=0, int screendy=0)
void drawScaledImage ()

Private Attributes

float _zoom
QImage _image
float _padding
float _maxZoomFactor
bool _mouseDown
int _mouseX
int _mouseY
QRect _view
float _desiredX
float _desiredY

Detailed Description

Definition at line 37 of file zimageview.h.


Constructor & Destructor Documentation

ZImageView::ZImageView ( QWidget *  parent = 0  ) 

Default constructor.

Definition at line 36 of file zimageview.cpp.

References _desiredX, _desiredY, _maxZoomFactor, _mouseDown, _padding, _zoom, resetZoomPoint(), and updateViewport().


Member Function Documentation

void ZImageView::setImage ( QImage &  pixmap  ) 

Sets the displayed image.

Definition at line 55 of file zimageview.cpp.

References _image, resetZoomPoint(), and updateViewport().

Referenced by TorMapWidget::TorMapWidget().

void ZImageView::resetZoomPoint (  )  [slot]

Resets the center zoom point back to the center of the viewport.

Definition at line 267 of file zimageview.cpp.

References _desiredX, _desiredY, and _view.

Referenced by mousePressEvent(), mouseReleaseEvent(), setImage(), ZImageView(), and TorMapWidget::zoomToFit().

void ZImageView::zoom ( float  pct  )  [slot]

Sets the current zoom level to the given percent.

Definition at line 295 of file zimageview.cpp.

References _zoom.

Referenced by zoom(), zoomIn(), zoomOut(), and TorMapWidget::zoomToFit().

void ZImageView::zoom ( QPoint  zoomAt,
float  pct 
) [slot]

Sets the current zoom level to the given percent and scrolls the window to place the specified point in the middle.

Definition at line 286 of file zimageview.cpp.

References _desiredX, _desiredY, and zoom().

void ZImageView::zoomIn (  )  [slot]

Zooms into the displayed image by 5%

Definition at line 303 of file zimageview.cpp.

References _zoom, and zoom().

void ZImageView::zoomOut (  )  [slot]

Zooms away from the displayed image by 5%

Definition at line 310 of file zimageview.cpp.

References _zoom, and zoom().

virtual void ZImageView::paintImage ( QPainter *  painter  )  [inline, protected, virtual]

Virtual method to let subclasses paint on the image before it's scaled.

Reimplemented in TorMapWidget.

Definition at line 62 of file zimageview.h.

Referenced by drawScaledImage().

void ZImageView::paintEvent ( QPaintEvent *   )  [protected, virtual]

Updates the viewport and repaints the displayed image.

Definition at line 277 of file zimageview.cpp.

References drawScaledImage(), and updateViewport().

void ZImageView::mousePressEvent ( QMouseEvent *  e  )  [protected, virtual]

Handles the user pressing a mouse button.

Definition at line 317 of file zimageview.cpp.

References _mouseDown, _mouseX, _mouseY, and resetZoomPoint().

void ZImageView::mouseReleaseEvent ( QMouseEvent *  e  )  [protected, virtual]

Handles the user releasing a mouse button.

Definition at line 328 of file zimageview.cpp.

References _mouseDown, resetZoomPoint(), and updateViewport().

void ZImageView::mouseMoveEvent ( QMouseEvent *  e  )  [protected, virtual]

Handles the user moving the mouse.

Definition at line 339 of file zimageview.cpp.

References _mouseX, _mouseY, _zoom, and updateViewport().

void ZImageView::resizeEvent ( QResizeEvent *  e  )  [protected, virtual]

Handles events where the widget is resized.

Definition at line 355 of file zimageview.cpp.

QPair< QRect, QRect > ZImageView::updateViewport ( int  screendx = 0,
int  screendy = 0 
) [protected]

Update the viewport. This will set _view to a region that, when copied from the image and scaled to the screen size, will show what is expected. The _view may be larger in one or more directions than the image, and you must deal with the non-overlapping regions.

Returns the _zoom==0.0 viewport rect (the max) and the _zoom==1.0 viewport rect (the min).

Definition at line 159 of file zimageview.cpp.

References _desiredX, _desiredY, _image, _maxZoomFactor, _padding, _view, and _zoom.

Referenced by mouseMoveEvent(), mouseReleaseEvent(), paintEvent(), setImage(), and ZImageView().

void ZImageView::drawScaledImage (  )  [protected]

Redraws the scaled image in the viewport.

Make a copy of the image so we don't ruin the original

Create a QPainter that draws directly on the copied image and call the virtual function to draw whatever the subclasses need to on the image.

Rescale the image copy

Definition at line 68 of file zimageview.cpp.

References _image, _view, i(), p(), and paintImage().

Referenced by paintEvent().


Member Data Documentation

float ZImageView::_zoom [private]

The current zoom level.

Definition at line 87 of file zimageview.h.

Referenced by mouseMoveEvent(), updateViewport(), ZImageView(), zoom(), zoomIn(), and zoomOut().

QImage ZImageView::_image [private]

The displayed image.

Definition at line 88 of file zimageview.h.

Referenced by drawScaledImage(), setImage(), and updateViewport().

float ZImageView::_padding [private]

Amount of padding to use on the side of the image.

Definition at line 89 of file zimageview.h.

Referenced by updateViewport(), and ZImageView().

float ZImageView::_maxZoomFactor [private]

Maximum amount to zoom into the image.

Definition at line 90 of file zimageview.h.

Referenced by updateViewport(), and ZImageView().

bool ZImageView::_mouseDown [private]

Set to true when a mouse button is depressed.

Definition at line 92 of file zimageview.h.

Referenced by mousePressEvent(), mouseReleaseEvent(), and ZImageView().

int ZImageView::_mouseX [private]

The x-coordinate of the current mouse position.

Definition at line 93 of file zimageview.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

int ZImageView::_mouseY [private]

The y-coordinate of the current mouse position.

Definition at line 94 of file zimageview.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

QRect ZImageView::_view [private]

The displayed viewport.

Definition at line 96 of file zimageview.h.

Referenced by drawScaledImage(), resetZoomPoint(), and updateViewport().

float ZImageView::_desiredX [private]

The X value we desire (???).

Definition at line 97 of file zimageview.h.

Referenced by resetZoomPoint(), updateViewport(), ZImageView(), and zoom().

float ZImageView::_desiredY [private]

The Y value we desire (???).

Definition at line 98 of file zimageview.h.

Referenced by resetZoomPoint(), updateViewport(), ZImageView(), and zoom().


The documentation for this class was generated from the following files:
Generated on Mon Oct 23 20:08:16 2006 for Vidalia by  doxygen 1.5.0