#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) |
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 36 of file zimageview.h.
ZImageView::ZImageView | ( | QWidget * | parent = 0 |
) |
Default constructor.
Constructor.
Definition at line 44 of file zimageview.cpp.
References _desiredX, _desiredY, _maxZoomFactor, _padding, _zoom, CURSOR_NORMAL, resetZoomPoint(), and updateViewport().
void ZImageView::setImage | ( | QImage & | img | ) |
Sets the displayed image.
Definition at line 62 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.
Resets the zoom point back to the center of the viewport.
Definition at line 271 of file zimageview.cpp.
References _desiredX, _desiredY, and _view.
Referenced by mouseDoubleClickEvent(), mouseReleaseEvent(), setImage(), ZImageView(), and TorMapWidget::zoomToFit().
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 299 of file zimageview.cpp.
References _zoom.
Referenced by zoom(), zoomIn(), zoomOut(), TorMapWidget::zoomToCircuit(), TorMapWidget::zoomToFit(), and TorMapWidget::zoomToRouter().
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 290 of file zimageview.cpp.
void ZImageView::zoomIn | ( | ) | [slot] |
Zooms into the displayed image by 5%
Zooms into the image by 10%
Definition at line 307 of file zimageview.cpp.
Referenced by mouseDoubleClickEvent().
void ZImageView::zoomOut | ( | ) | [slot] |
Zooms away from the displayed image by 5%
Zooms away from the image by 10%
Definition at line 314 of file zimageview.cpp.
Referenced by mouseDoubleClickEvent().
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 61 of file zimageview.h.
Referenced by drawScaledImage().
void ZImageView::paintEvent | ( | QPaintEvent * | ) | [protected, virtual] |
Updates the viewport and repaints the displayed image.
Handles repainting this widget by updating the viewport and drawing the scaled image.
Definition at line 281 of file zimageview.cpp.
References drawScaledImage(), and updateViewport().
void ZImageView::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Handles the user pressing a mouse button.
Responds to the user pressing a mouse button.
Definition at line 321 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.
Responds to the user releasing a mouse button.
Definition at line 331 of file zimageview.cpp.
References CURSOR_NORMAL, resetZoomPoint(), and updateViewport().
void ZImageView::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Handles the user moving the mouse.
Responds to the user moving the mouse.
Definition at line 362 of file zimageview.cpp.
References _mouseX, _mouseY, _zoom, and updateViewport().
void ZImageView::mouseDoubleClickEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
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 343 of file zimageview.cpp.
References resetZoomPoint(), updateViewport(), zoomIn(), and zoomOut().
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 166 of file zimageview.cpp.
References _desiredX, _desiredY, _image, _maxZoomFactor, _padding, _view, and _zoom.
Referenced by mouseDoubleClickEvent(), mouseMoveEvent(), mouseReleaseEvent(), paintEvent(), setImage(), and ZImageView().
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 75 of file zimageview.cpp.
References _image, _view, i(), p(), and paintImage().
Referenced by paintEvent().
float ZImageView::_zoom [private] |
The current zoom level.
Definition at line 83 of file zimageview.h.
Referenced by mouseMoveEvent(), updateViewport(), ZImageView(), zoom(), zoomIn(), and zoomOut().
QImage ZImageView::_image [private] |
The displayed image.
Definition at line 84 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 85 of file zimageview.h.
Referenced by updateViewport(), and ZImageView().
float ZImageView::_maxZoomFactor [private] |
Maximum amount to zoom into the image.
Definition at line 86 of file zimageview.h.
Referenced by updateViewport(), and ZImageView().
int ZImageView::_mouseX [private] |
The x-coordinate of the current mouse position.
Definition at line 88 of file zimageview.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
int ZImageView::_mouseY [private] |
The y-coordinate of the current mouse position.
Definition at line 89 of file zimageview.h.
Referenced by mouseMoveEvent(), and mousePressEvent().
QRect ZImageView::_view [private] |
The displayed viewport.
Definition at line 91 of file zimageview.h.
Referenced by drawScaledImage(), resetZoomPoint(), and updateViewport().
float ZImageView::_desiredX [private] |
The X value we desire (???).
Definition at line 92 of file zimageview.h.
Referenced by resetZoomPoint(), updateViewport(), ZImageView(), and zoom().
float ZImageView::_desiredY [private] |
The Y value we desire (???).
Definition at line 93 of file zimageview.h.
Referenced by resetZoomPoint(), updateViewport(), ZImageView(), and zoom().