classPiiImageViewport
#include <PiiImageViewport.h>
A widget for viewing QImages.
Inherits QWidget
Description
Main features:
-
Zooming with keys + and -, and using mouse wheel.
-
Mouse dragging (This requires that the widget is placed into a PiiScrollArea, see #setScrollArea(PiiScrollArea*))
-
Three states: Fit to view, Fill view and No fit (default state).
Properties
|
The fit mode of the image in the viewport. |
|
|
QSizeF
|
The physical size of a pixel in millimeters. |
|
int
|
The unit system for displaying distance and area measurements in the image. |
Public types
|
enum
|
{ NoFit = 0x00, FitToView, FillView }
Enumeration, which is used for determining the fit mode of the image in the viewport. |
|
enum
|
{ FocusToMouseCursor = 0x00, FocusToWidgetTopLeft }
Enumeration, which is used for determining the focus point for example in zooming or resizing. |
Public Slots
|
void
|
( )
This slot sets the zoom factor to 1. |
|
void
|
( )
This slot sets the state of the image viewport to "Fit to View". |
|
void
|
( )
This slot sets the state of the image viewport to "Fill View" . |
|
void
|
( )
This slot sets the state of the image viewport to "Fit to View" . |
|
void
|
This slot sets overlay coloring on/off. |
|
void
|
( )
This slot sets the zoom factor as double. |
|
void
|
( )
Requests a redraw of the image. |
|
void
|
( )
This slot zooms in by the factor determined by the property
|
|
void
|
( )
This slot zooms out by the factor determined by the property
|
Signals
|
void
|
Emitted when the user has finished selecting a rectangular area from the image. |
|
void
|
Notify the location of mouse click on image coordinate system. |
|
void
|
( )
|
|
void
|
( )
|
|
void
|
( )
Emit signals pageUp, pageDown and esc when them buttons pressed. |
|
void
|
(
This signal is emitted, once the visible area compared to the parent widget changes in this widget. |
Constructors and destructor
|
|
|
|
PiiImageViewport constructor. |
|
|
PiiImageViewport constructor. |
|
Public member functions
|
void
|
|
|
void
|
|
|
void
|
Adds overlay to the viewport. |
|
( )
|
|
|
QImage *
|
(
Returns pointer to current image on viewport. |
|
bool
|
(
|
|
int
|
( )
|
|
double
|
(
|
|
QSizeF
|
( )
|
|
void
|
(
|
|
void
|
Remove given overlay from image. |
|
void
|
|
|
void
|
Set current image on the viewport, resize the component. |
|
void
|
Works similarly than the other setImage function, except the memory management works differently. |
|
void
|
(
|
|
void
|
(
|
|
void
|
Changes current set of overlays with new one. |
|
void
|
(
|
|
void
|
(
|
|
int
|
( )
|
|
double
|
( )
Returns the zoom factor. |
Protected member functions
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
|
|
void
|
|
Friends
|
friend class
|
|
|
friend class
|
|
Property details
-
FitMode fitMode
[read, write]The fit mode of the image in the viewport.
The default is
NoFit. -
QSizeF pixelSize
[read, write]The physical size of a pixel in millimeters.
-
int unitSystem
[read, write]The unit system for displaying distance and area measurements in the image.
See PiiUnitConverter for valid values. -1 (the default) means no unit system. Measurements on the image are shown in the selected unit system, to which pixels are scaled with pixelSize.
Enumeration details
-
enum FitMode
Enumeration, which is used for determining the fit mode of the image in the viewport.
With the fit modes
FitToViewandFillViewthe zoom factor is changed automatically, when the image viewport is resized. Regardless of the fit mode, the aspect ratio of the image remains the same. The following values are determined:-
NoFit- there is no fit, the image is not rescaled, when the image viewport is resized. -
FitToView- when viewport is resized, the image is rescaled as big as possible inside the viewport widget area, preserving the aspect ratio, and still fitting in inside the image viewport widget. -
FillView- when image is resized, the image is scaled as small as possible outside the image viewport, filling the whole image viewport area and preserving the aspect ratio.
-
-
enum FocusPolicy
Enumeration, which is used for determining the focus point for example in zooming or resizing.
Has the following possible values:
-
FocusPointMouseCursor- the image is focused to the mouse cursor. -
FocusPointTopLeft- the image is focused to the top left corner of the widget. -
FocusPointTopLeft- the image is focused to the center of the widget. -
FocusPointTopLeft- the image is focused to the center of the image.
-
Function details
-
PiiImageViewport
-
PiiImageViewport constructor.
Use this version of the constructor, if you want to use Qt's implicit memory sharing mechanism for the QImage object. When using this constructor, you don't have to care about references to the QImage object outside the PiiImageViewport class.
-
PiiImageViewport constructor.
Use this constructor, if you don't want to use Qt's implicit memory sharing mechanism for the QImage object, and you are sure that the QImage object, whose content is shown on the image viewport, is stored somewhere else, when the image is in the viewport. If these conditions are not fullfilled, use the other constructor in stead.
-
~PiiImageViewport
() -
void addLayer
-
void addLayer
-
void addOverlay
Adds overlay to the viewport.
See the documentation of
PiiImageOverlayfor more details about the overlays. -
FitMode fitMode
() -
QImage * image
(- int layer = 0
Returns pointer to current image on viewport.
-
bool isLayerVisible
(- int layer
-
int layerCount
() -
double opacity
(- int layer
-
QSizeF pixelSize
() -
void removeLayer
(- int index
-
void removeOverlay
Remove given overlay from image.
If parameter is 0, ALL overlays are removed
-
void setFitMode
-
void setImage
Set current image on the viewport, resize the component.
Use this version of the function, if you don't want to use Qt's implicit memory sharing mechanism for the QImage object, and you are sure that the QImage object, whose content is shown on the image viewport, is stored somewhere else, when the image is in the viewport. If these conditions are not fullfilled, use the other version of the setImage function in stead.
-
void setImage
Works similarly than the other setImage function, except the memory management works differently.
Use this version of the function, if you want to use Qt's implicit memory sharing mechanism for the QImage object. When using this function, you don't have to care about references to the QImage object outside the PiiImageViewport class.
-
void setLayerVisible
(- bool visible
- int layer
-
void setOpacity
(- double opacity
- int layer
-
void setOverlays
Changes current set of overlays with new one.
NOTE: ALL old overlays are removed.
-
void setPixelSize
(- QSizeF pixelSize
-
void setUnitSystem
(- int unitSystem
-
int unitSystem
() -
double zoom
()Returns the zoom factor.
-
-
-
-
-
-
-
-
-
-
Emitted when the user has finished selecting a rectangular area from the image.
The coordinates are represented in image domain.
-
Notify the location of mouse click on image coordinate system.
-
void escPressed
()[signal] -
void pageDownPressed
()[signal] -
void pageUpPressed
()[signal]Emit signals pageUp, pageDown and esc when them buttons pressed.
-
void visibleAreaChanged
(- int x
- int y
- int width
- int height
[signal]This signal is emitted, once the visible area compared to the parent widget changes in this widget.
The signal is emitted only if the size of widget is greater than the size of the parent widget. If the parent widget is QScrollArea (or class derived from that), widget being greater than the parent widget means, that there are scroll bars in the scroll area.
-
void actualSize
()[slot]This slot sets the zoom factor to 1.
-
void fitToView
()[slot]This slot sets the state of the image viewport to "Fit to View".
-
void setFillView
()[slot]This slot sets the state of the image viewport to "Fill View" .
When "Fill View" state is on, the image is scaled automatically so, that it takes all the room in the image viewport either in the x or y direction, keeping the original aspect ratio. It means that not necessarily everything of the image is shown in the image viewport, because in one direction not everything is shown. The state remains, until the image is zoomed in or zoomed out. In that case the state changes to "No Fit". Resizing doesn't change the state.
-
void setFitToView
()[slot]This slot sets the state of the image viewport to "Fit to View" .
When "Fit to View" state is on, the image is scaled automatically so that it fits entirely in the image viewport in the both directions, keeping the original aspect ratio. The state remains, until the image is zoomed in or zoomed out. In that case the state changes to "No Fit". Resizing doesn't change the state.
-
void setShowOverlayColoring
()[slot]This slot sets overlay coloring on/off.
-
void setZoom
()[slot]This slot sets the zoom factor as double.
1.0 is the image in the actual size.
-
void updateImage
()[slot]Requests a redraw of the image.
This function is useful for example if you modify the appearance of an overlay.
-
void zoomIn
()[slot]This slot zooms in by the factor determined by the property
zoomStep(property not implemented yet). -
void zoomOut
()[slot]This slot zooms out by the factor determined by the property
zoomStep(property not implemented yet).
Add a note
Not a single note added yet. Be the first, add yours.