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 mouseDoubleClickEvent (QMouseEvent *e)
virtual void wheelEvent (QWheelEvent *e)
void updateViewport (int screendx=0, int screendy=0)
void drawScaledImage ()

Private Attributes

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

Detailed Description

Definition at line 25 of file zimageview.h.


Constructor & Destructor Documentation

ZImageView::ZImageView ( QWidget *  parent = 0  ) 

Default constructor.

Definition at line 33 of file zimageview.cpp.

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


Member Function Documentation

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 64 of file zimageview.cpp.

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

Referenced by paintEvent().

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

Handles the user double-clicking a mouse button.

Definition at line 332 of file zimageview.cpp.

References resetZoomPoint(), updateViewport(), zoomIn(), and zoomOut().

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

Handles the user moving the mouse.

Definition at line 351 of file zimageview.cpp.

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

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

Handles the user pressing a mouse button.

Definition at line 310 of file zimageview.cpp.

References _mouseX, _mouseY, and CURSOR_MOUSE_PRESS.

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

Handles the user releasing a mouse button.

Definition at line 320 of file zimageview.cpp.

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

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

Updates the viewport and repaints the displayed image.

Definition at line 270 of file zimageview.cpp.

References drawScaledImage(), and updateViewport().

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 50 of file zimageview.h.

Referenced by drawScaledImage().

void ZImageView::resetZoomPoint (  )  [slot]

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

Definition at line 260 of file zimageview.cpp.

References _desiredX, _desiredY, and _view.

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

void ZImageView::setImage ( QImage &  pixmap  ) 

Sets the displayed image.

Definition at line 51 of file zimageview.cpp.

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

Referenced by TorMapWidget::TorMapWidget().

void 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.

Definition at line 155 of file zimageview.cpp.

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

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

void ZImageView::wheelEvent ( QWheelEvent *  e  )  [protected, virtual]

Handles the wheel events.

Definition at line 366 of file zimageview.cpp.

References zoomIn(), and zoomOut().

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 279 of file zimageview.cpp.

References _desiredX, _desiredY, and zoom().

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

Sets the current zoom level to the given percent.

Definition at line 288 of file zimageview.cpp.

References _zoom.

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

void ZImageView::zoomIn (  )  [slot]

Zooms into the displayed image by 5%

Definition at line 296 of file zimageview.cpp.

References _zoom, and zoom().

Referenced by mouseDoubleClickEvent(), and wheelEvent().

void ZImageView::zoomOut (  )  [slot]

Zooms away from the displayed image by 5%

Definition at line 303 of file zimageview.cpp.

References _zoom, and zoom().

Referenced by mouseDoubleClickEvent(), and wheelEvent().


Member Data Documentation

float ZImageView::_desiredX [private]

The X value we desire (???).

Definition at line 83 of file zimageview.h.

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

float ZImageView::_desiredY [private]

The Y value we desire (???).

Definition at line 84 of file zimageview.h.

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

QImage ZImageView::_image [private]

The displayed image.

Definition at line 75 of file zimageview.h.

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

float ZImageView::_maxZoomFactor [private]

Maximum amount to zoom into the image.

Definition at line 77 of file zimageview.h.

Referenced by updateViewport(), and ZImageView().

int ZImageView::_mouseX [private]

The x-coordinate of the current mouse position.

Definition at line 79 of file zimageview.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

int ZImageView::_mouseY [private]

The y-coordinate of the current mouse position.

Definition at line 80 of file zimageview.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

float ZImageView::_padding [private]

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

Definition at line 76 of file zimageview.h.

Referenced by updateViewport(), and ZImageView().

QRect ZImageView::_view [private]

The displayed viewport.

Definition at line 82 of file zimageview.h.

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

float ZImageView::_zoom [private]

The current zoom level.

Definition at line 74 of file zimageview.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jul 7 17:00:57 2009 for Vidalia by  doxygen 1.4.7