Class ImageView

Inheritance Relationships

Base Type

Class Documentation

class ImageView : public nanogui::Widget

Widget used to display images.

Public Functions

ImageView(Widget *parent, GLuint imageID)
~ImageView()
void bindImage(GLuint imageId)
GLShader &imageShader()
Vector2f positionF() const
Vector2f sizeF() const
const Vector2i &imageSize() const
Vector2i scaledImageSize() const
Vector2f imageSizeF() const
Vector2f scaledImageSizeF() const
const Vector2f &offset() const
void setOffset(const Vector2f &offset)
float scale() const
void setScale(float scale)
bool fixedOffset() const
void setFixedOffset(bool fixedOffset)
bool fixedScale() const
void setFixedScale(bool fixedScale)
float zoomSensitivity() const
void setZoomSensitivity(float zoomSensitivity)
float gridThreshold() const
void setGridThreshold(float gridThreshold)
float pixelInfoThreshold() const
void setPixelInfoThreshold(float pixelInfoThreshold)
void setFontScaleFactor(float fontScaleFactor)
float fontScaleFactor() const
Vector2f imageCoordinateAt(const Vector2f &position) const

Calculates the image coordinates of the given pixel position on the widget.

Vector2f clampedImageCoordinateAt(const Vector2f &position) const

Calculates the image coordinates of the given pixel position on the widget. If the position provided corresponds to a coordinate outside the range of the image, the coordinates are clamped to edges of the image.

Vector2f positionForCoordinate(const Vector2f &imageCoordinate) const

Calculates the position inside the widget for the given image coordinate.

void setImageCoordinateAt(const Vector2f &position, const Vector2f &imageCoordinate)

Modifies the internal state of the image viewer widget so that the pixel at the provided position on the widget has the specified image coordinate. Also clamps the values of offset to the sides of the widget.

void center()

Centers the image without affecting the scaling factor.

void fit()

Centers and scales the image so that it fits inside the widgets.

void setScaleCentered(float scale)

Set the scale while keeping the image centered.

void moveOffset(const Vector2f &delta)

Moves the offset by the specified amount. Does bound checking.

void zoom(int amount, const Vector2f &focusPosition)

Changes the scale factor by the provided amount modified by the zoom sensitivity member variable. The scaling occurs such that the image coordinate under the focused position remains in the same position before and after the scaling.

bool keyboardEvent(int key, int scancode, int action, int modifiers)

Handle a keyboard event (default implementation: do nothing)

bool keyboardCharacterEvent(unsigned int codepoint)

Handle text input (UTF-32 format) (default implementation: do nothing)

bool mouseDragEvent(const Vector2i &p, const Vector2i &rel, int button, int modifiers)

Handle a mouse drag event (default implementation: do nothing)

bool scrollEvent(const Vector2i &p, const Vector2f &rel)

Handle a mouse scroll event (default implementation: propagate to children)

bool gridVisible() const

Function indicating whether the grid is currently visible.

bool pixelInfoVisible() const

Function indicating whether the pixel information is currently visible.

bool helpersVisible() const

Function indicating whether any of the overlays are visible.

Vector2i preferredSize(NVGcontext *ctx) const

Compute the preferred size of the widget.

void performLayout(NVGcontext *ctx)

Invoke the associated layout generator to properly place child widgets, if any.

void draw(NVGcontext *ctx)

Draw the widget (and all child widgets)