Vidalia
0.3.1
|
#include <ZImageView.h>
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 |
Definition at line 24 of file ZImageView.h.
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().
|
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(), and paintImage().
|
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().
Referenced by paintImage().
|
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().
Referenced by paintImage().
|
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.
Referenced by paintImage().
|
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().
Referenced by paintImage().
|
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().
Referenced by paintImage().
|
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.
References drawScaledImage(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), updateViewport(), and wheelEvent().
Referenced by drawScaledImage().
|
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().
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().
|
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(), paintImage(), setImage(), and ZImageView().
|
protectedvirtual |
Handles the wheel events.
Definition at line 366 of file ZImageView.cpp.
References zoomIn(), and zoomOut().
Referenced by paintImage().
|
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().
|
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.
|
slot |
Zooms into the displayed image by 5%
Zooms into the image by 10%
Definition at line 296 of file ZImageView.cpp.
Referenced by mouseDoubleClickEvent(), wheelEvent(), and NetViewer::zoomIn().
|
slot |
Zooms away from the displayed image by 5%
Zooms away from the image by 10%
Definition at line 303 of file ZImageView.cpp.
Referenced by mouseDoubleClickEvent(), wheelEvent(), and NetViewer::zoomOut().
|
private |
The X value we desire (???).
Definition at line 82 of file ZImageView.h.
Referenced by resetZoomPoint(), updateViewport(), ZImageView(), and zoom().
|
private |
The Y value we desire (???).
Definition at line 83 of file ZImageView.h.
Referenced by resetZoomPoint(), updateViewport(), ZImageView(), and zoom().
|
private |
The displayed image.
Definition at line 74 of file ZImageView.h.
Referenced by drawScaledImage(), setImage(), and updateViewport().
|
private |
Maximum amount to zoom into the image.
Definition at line 76 of file ZImageView.h.
Referenced by updateViewport(), and ZImageView().
|
private |
The x-coordinate of the current mouse position.
Definition at line 78 of file ZImageView.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
|
private |
The y-coordinate of the current mouse position.
Definition at line 79 of file ZImageView.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
|
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().
|
private |
The displayed viewport.
Definition at line 81 of file ZImageView.h.
Referenced by drawScaledImage(), resetZoomPoint(), and updateViewport().
|
private |
The current zoom level.
Definition at line 73 of file ZImageView.h.
Referenced by mouseMoveEvent(), updateViewport(), ZImageView(), zoom(), zoomIn(), and zoomOut().