Vidalia 0.3.1
Public Slots | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
ZImageView Class Reference

#include <ZImageView.h>

Inheritance diagram for ZImageView:
TorMapImageView

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 24 of file ZImageView.h.

Constructor & Destructor Documentation

◆ ZImageView()

ZImageView::ZImageView ( QWidget *  parent = 0)

Default constructor.

Constructor.

Definition at line 33 of file ZImageView.cpp.

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

Member Function Documentation

◆ drawScaledImage()

void ZImageView::drawScaledImage ( )
protected

Redraws the scaled image in the viewport.

Draws the scaled image on the widget.

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().

◆ mouseDoubleClickEvent()

void ZImageView::mouseDoubleClickEvent ( QMouseEvent *  e)
protectedvirtual

Handles the user double-clicking a mouse button.

Responds to the user double-clicking a mouse button on the image. A left double-click zooms in on the image and a right double-click zooms out. Zooming is centered on the location of the double-click.

Definition at line 332 of file ZImageView.cpp.

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

◆ mouseMoveEvent()

void ZImageView::mouseMoveEvent ( QMouseEvent *  e)
protectedvirtual

Handles the user moving the mouse.

Responds to the user moving the mouse.

Definition at line 351 of file ZImageView.cpp.

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

◆ mousePressEvent()

void ZImageView::mousePressEvent ( QMouseEvent *  e)
protectedvirtual

Handles the user pressing a mouse button.

Responds to the user pressing a mouse button.

Definition at line 310 of file ZImageView.cpp.

References _mouseX, _mouseY, and CURSOR_MOUSE_PRESS.

◆ mouseReleaseEvent()

void ZImageView::mouseReleaseEvent ( QMouseEvent *  e)
protectedvirtual

Handles the user releasing a mouse button.

Responds to the user releasing a mouse button.

Definition at line 320 of file ZImageView.cpp.

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

◆ paintEvent()

void ZImageView::paintEvent ( QPaintEvent *  )
protectedvirtual

Updates the viewport and repaints the displayed image.

Handles repainting this widget by updating the viewport and drawing the scaled image.

Definition at line 270 of file ZImageView.cpp.

References drawScaledImage(), and updateViewport().

◆ paintImage()

virtual void ZImageView::paintImage ( QPainter *  painter)
inlineprotectedvirtual

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

Reimplemented in TorMapImageView.

Definition at line 49 of file ZImageView.h.

Referenced by drawScaledImage().

◆ resetZoomPoint

void ZImageView::resetZoomPoint ( )
slot

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

Resets the 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 TorMapImageView::zoomToFit().

◆ setImage()

void ZImageView::setImage ( QImage &  img)

Sets the displayed image.

Definition at line 51 of file ZImageView.cpp.

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

Referenced by TorMapImageView::TorMapImageView().

◆ updateViewport()

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.

Updates the displayed viewport.

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().

◆ wheelEvent()

void ZImageView::wheelEvent ( QWheelEvent *  e)
protectedvirtual

Handles the wheel events.

Definition at line 366 of file ZImageView.cpp.

References zoomIn(), and zoomOut().

◆ zoom [1/2]

void ZImageView::zoom ( float  pct)
slot

Sets the current zoom level to the given percent.

Sets the current zoom percentage to the given value.

Definition at line 288 of file ZImageView.cpp.

References _zoom.

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

◆ zoom [2/2]

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.

Sets the current zoom percentage to the given value and scrolls the viewport to center the given point.

Definition at line 279 of file ZImageView.cpp.

References _desiredX, _desiredY, and zoom().

◆ zoomIn

void ZImageView::zoomIn ( )
slot

Zooms into the displayed image by 5%

Zooms into the image by 10%

Definition at line 296 of file ZImageView.cpp.

References _zoom, and zoom().

Referenced by mouseDoubleClickEvent(), wheelEvent(), and NetViewer::zoomIn().

◆ zoomOut

void ZImageView::zoomOut ( )
slot

Zooms away from the displayed image by 5%

Zooms away from the image by 10%

Definition at line 303 of file ZImageView.cpp.

References _zoom, and zoom().

Referenced by mouseDoubleClickEvent(), wheelEvent(), and NetViewer::zoomOut().

Member Data Documentation

◆ _desiredX

float ZImageView::_desiredX
private

The X value we desire (???).

Definition at line 82 of file ZImageView.h.

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

◆ _desiredY

float ZImageView::_desiredY
private

The Y value we desire (???).

Definition at line 83 of file ZImageView.h.

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

◆ _image

QImage ZImageView::_image
private

The displayed image.

Definition at line 74 of file ZImageView.h.

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

◆ _maxZoomFactor

float ZImageView::_maxZoomFactor
private

Maximum amount to zoom into the image.

Definition at line 76 of file ZImageView.h.

Referenced by updateViewport(), and ZImageView().

◆ _mouseX

int ZImageView::_mouseX
private

The x-coordinate of the current mouse position.

Definition at line 78 of file ZImageView.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ _mouseY

int ZImageView::_mouseY
private

The y-coordinate of the current mouse position.

Definition at line 79 of file ZImageView.h.

Referenced by mouseMoveEvent(), and mousePressEvent().

◆ _padding

float ZImageView::_padding
private

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

Definition at line 75 of file ZImageView.h.

Referenced by updateViewport(), and ZImageView().

◆ _view

QRect ZImageView::_view
private

The displayed viewport.

Definition at line 81 of file ZImageView.h.

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

◆ _zoom

float ZImageView::_zoom
private

The current zoom level.

Definition at line 73 of file ZImageView.h.

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


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