golib  0.5
goGUI::ImageView Class Reference

Image display widget. More...

#include <imageview.h>

Public Types

enum  { IMAGE_SET, IMAGE_REMOVED, CURRENT_IMAGE_CHANGED }
 

Public Member Functions

void draw ()
 
void setImage (const goSignal3DBase< void > &image, goIndex_t index=-1)
 Sets the image to draw. More...
 
void setImage (int w, int h, int format=goPlot::Object2DImage::RGB24, goIndex_t index=-1)
 Sets the image dimensions and format. A cairo image is created. More...
 
goAutoPtr< goPlot::Object2DImagegetImageObject (goIndex_t index=-1)
 Get the image from this object. More...
 
goAutoPtr< goSignal3DBase< void > > getImage (goIndex_t index=-1)
 Get the image from this object. More...
 
void removeImage (goIndex_t index=-1)
 
void reorderImages (const std::vector< int > &order)
 
goIndex_t getImageCount () const
 
goAutoPtr< goPlot::Graphgraph ()
 Get the Graph object used to draw the image. More...
 
void setCurrentImage (goIndex_t i)
 
goIndex_t currentImageIndex () const
 
goCaller1< void, int > & changedCaller ()
 

Protected Member Functions

virtual bool on_draw (Cairo::RefPtr< Cairo::Context > const &context) override
 Draws everything. More...
 
goAutoPtr< goSignal3DBase< void > > imageRef (goAutoPtr< goPlot::Object2DImage > img)
 Creates an object that references the data in the Object2DImage directly. More...
 

Detailed Description

Image display widget.

Bug:
Check imageview.cpp for FIXME — a setDimensions call to goPlot::Graph crashes somewhere in pango. The call is commented out for now.

ImageView uses a goPlot::Graph to display objects with Cairo. For an image set with setImage(), a buffer will be created, so the image data, if any, will be copied. A wrapping goSignal3DBase referencing that buffer can be retrieved with getImage(). The goPlot::Object2DImage that represents the same image data can be retrieved with getImageObject().

The data type of the image data is unsigned char, or GO_UINT8 in golib notation. The number of channels is either 4 or 1, depending on whether the format is goPlot::Object2DImage::RGB24 , goPlot::Object2DImage::ARGB32 (both 4 channels) or goPlot::Object2DImage::A8. This widget can display images from goSignal3DBase<void> objects.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
IMAGE_SET 

Value for changedCaller.

IMAGE_REMOVED 

Value for changedCaller.

CURRENT_IMAGE_CHANGED 

Value for changedCaller.

Member Function Documentation

◆ getImage()

goAutoPtr< goSignal3DBase< void > > goGUI::ImageView::getImage ( goIndex_t  index = -1)

Get the image from this object.

See also
getImageObject()
Returns
Reference to the stored image object.

◆ getImageObject()

goAutoPtr< goPlot::Object2DImage > goGUI::ImageView::getImageObject ( goIndex_t  index = -1)

Get the image from this object.

See also
getImage()
Returns
Reference to the stored image object.

◆ graph()

goAutoPtr< goPlot::Graph > goGUI::ImageView::graph ( )

Get the Graph object used to draw the image.

Returns
goAutoPtr to the goPlot::Graph object.

◆ imageRef()

goAutoPtr< goSignal3DBase< void > > goGUI::ImageView::imageRef ( goAutoPtr< goPlot::Object2DImage img)
protected

Creates an object that references the data in the Object2DImage directly.

The data in the object is organised linearly, rows first. If the internal image format is ARGB32 or RGB24, the number of channels is 4. Otherwise, the number of channels is 1. The data type is always GO_UINT8.

The returned object should be a goSignal3DRef and has border size (8,8,0) set.

Returns
Pointer to the reference.

◆ on_draw()

bool goGUI::ImageView::on_draw ( Cairo::RefPtr< Cairo::Context > const &  context)
overrideprotectedvirtual

Draws everything.

Parameters
eventThe event.
Returns
True if successful, false otherwise.

◆ setImage() [1/2]

void goGUI::ImageView::setImage ( const goSignal3DBase< void > &  image,
goIndex_t  index = -1 
)

Sets the image to draw.

The image gets deep copied into a cairo image object. getImage() can be used to get a reference goSignal3DBase object which references the cairo image data directly. getImageObject() can be used to retrieve the respective goPlot::Object2DImage, giving the same data.

Parameters
imageImage to draw. The image gets copied, but gets copied into a uint8 type array. That means if the data range is out of the 8 bit range, it will get clamped.

◆ setImage() [2/2]

void goGUI::ImageView::setImage ( int  w,
int  h,
int  format = goPlot::Object2DImage::RGB24,
goIndex_t  index = -1 
)

Sets the image dimensions and format. A cairo image is created.

The formats can be found in goPlot::Object2DImage. getImage() can be used to get a reference goSignal3DBase object which references the cairo image data directly.

Parameters
wWidth
hHeight
formatFormat, such as goPlot::Object2DImage::RGB24.
indexIndex of the image (default -1). If index < 0, a new image is made.

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