Main Page | Namespace List | Compound List | File List | Namespace Members | Compound Members | File Members

KGLImageView::KGLImage Class Reference

#include <kglimageviewer.h>

List of all members.

Public Member Functions

 KGLImage ()
int width () const
int height () const
int basicWidth () const
int basicHeight () const
float alpha () const
bool hasAlpha () const
void setInternalColor (const QColor color)
QColor color () const
float brightness () const
float position (Axis a) const
float rotation (Axis a) const
float scaleFactor (Axis a) const
GLuint glObject () const
uint id () const
KGLImageViewerparent () const
bool isShown () const
void show (bool update=true)
void hide (bool update=true)
void rotate (Axis a, float degrees, int msecs=0)
void rotate (float xDegrees, float yDegrees, float zDegrees, bool update=true)
void rotateTo (Axis a, float degrees, int msecs=0)
void rotateTo (float xDegrees, float yDegrees, float zDegrees, bool update=true)
float scale (Axis a, float percent, int msecs=0)
void scale (float xPercent, float yPercent, bool update=true)
float scaleTo (Axis a, float percent, int msecs=0, bool viewRelative=false, float assumedViewScale=-1.0)
void scaleTo (float xPercent, float yPercent, bool update=true, bool viewRelative=false, float assumedViewScaleX=-1.0, float assumedViewScaleY=-1.0)
void move (Axis a, float percent, int msecs=0)
void move (float xPercent, float yPercent, float zPercent, bool update=true)
void moveTo (Axis a, float percent, int msecs=0)
void moveTo (float xPercent, float yPercent, float zPercent, bool update=true)
void setAlpha (float percent, int msecs=0)
void tint (const QColor &color, int msecs=0)
void setBrightness (float percent, int msecs=0)
void boxBlur (float factor, int msecs=0)
void tunnel (float factor, int msecs=0)
void blur (float factor, int msecs=0, int type=0)
float blurrage ()
void setClipRect (int x, int y, int w, int h, bool update=true)
void setClipRect (QRect &r, bool update=true)
void setClipping (bool enabled=true)
bool hasClipping () const
void invert (bool inverted=true, bool update=true)
bool isInverted ()
void resize (int width, int height, int msecs=0, float assumedViewScaleX=-1.0, float assumedViewScaleY=-1.0)
void addShader (GLhandleARB shader, bool linkProgram=true, bool update=true)
void addShader (QString file, GLenum shaderType, bool linkProgram=true, bool update=true)
void removeShader (GLhandleARB shader, bool relinkProgram=true, bool update=true)
GLhandleARB shaderProgram ()
void setShaderProgram (KGLImage &img)
ShaderListshaders ()
void setShaderUniform (const int var, const int varSize, const float val1, const float val2=0.0, const float val3=0.0, const float val4=0.0)
int setShaderUniform (QString var, const int varSize, const float val1, const float val2=0.0, const float val3=0.0, const float val4=0.0)

Protected Member Functions

void paint ()

Friends

class KGLImageViewer


Detailed Description

Images for the KGLImageViewer (GLlists and stuff around)

Author:
Thomas Lübking <thomas.luebking@web.de>


Constructor & Destructor Documentation

KGLImageView::KGLImage::KGLImage  )  [inline]
 

An empty constructor to make QValueList happy -- !! DON'T USE IT !!


Member Function Documentation

void KGLImageView::KGLImage::addShader QString  file,
GLenum  shaderType,
bool  linkProgram = true,
bool  update = true
[inline]
 

Convenience function. Calls addShader(KGLImageViewer::loadShader(file, shaderType), relinkProgram, update);

void KGLImageView::KGLImage::addShader GLhandleARB  shader,
bool  linkProgram = true,
bool  update = true
 

Adds a shader to the images pipeline

Parameters:
shader A shader previously loaded with KGLImageViewer::loadShader()
linkProgram If you want to add many shaders in a row, set this to false for any but the last one (performance issue)
update Whether to update the display after adding this shader (autoset to false if you're not linking, so addShader(myFancyShader, false, true) will NOT update the display)

float KGLImageView::KGLImage::alpha  )  const [inline]
 

Returns the current alpha level of the image
NOTICE: if the alpha value is set animated, this is NOT the final but allways the CURRENT!!! alpha value

int KGLImageView::KGLImage::basicHeight  )  const [inline]
 

Returns the original height of the image in pixles
different from height() this value stays the same all the time, no matter which operations on the image are performed

int KGLImageView::KGLImage::basicWidth  )  const [inline]
 

Returns the original width of the image in pixles
different from width() this value stays the same all the time, no matter which operations on the image are performed

void KGLImageView::KGLImage::blur float  factor,
int  msecs = 0,
int  type = 0
 

float KGLImageView::KGLImage::blurrage  )  [inline]
 

void KGLImageView::KGLImage::boxBlur float  factor,
int  msecs = 0
[inline]
 

Blur the image

Parameters:
factor How much ((blur kernel - 1)/2, i.e. blur(1) results in a 3x3 kernel)
msecs How fast (don't use animated blurring on big kernels - stupid idea)
(Qt4) Blurring is gained by painting several shifted translucent versions of the image over each other, so the higher the blur factor is, the more does it cost. The result is saved in a texture. (Qt3) The blurring is gained by creating a prefabbed boxblurred miniversion of the image and use the GL lienar upscaler and blending to create blurring effects (different from Qt4, this makes it necessary to blend and an additional gllist at paint time)

(Qt4) Blurring is pretty fast (as it's performed spatial), at least for not too big kernels. And accurate "enough" (though it's not like blurring with "The GIMP", but that's not the approach here)

(Qt4) if you pass "1" as blur type, a ceter motion blur is performed instead of a boxblur (i.e. the image blurs more to the edges and keeps sharp in the center). This function is O(1/2 * O(glScale) / O(glTranform)) compared to the boxblur (but of course a different effect)

Blur functions ARE EXCLUSIVE (i.e. you cannot perform a boxblur on top of the motion blur - at least for the moment)

float KGLImageView::KGLImage::brightness  )  const [inline]
 

Returns the current brightness of the image
NOTICE: if the brightness is set animated, this is NOT the final but allways the CURRENT!!! color

QColor KGLImageView::KGLImage::color  )  const [inline]
 

Returns the current tint color of the image
NOTICE: if the color is set animated, this is NOT the final but allways the CURRENT!!! color

GLuint KGLImageView::KGLImage::glObject  )  const [inline]
 

Returns the OpenGL index of this image
NOTICE: as long as you don't use flat copies of the image, this is unique - OTHERWISE NOT!

bool KGLImageView::KGLImage::hasAlpha  )  const [inline]
 

Whether the Image has an alpha channel
NOTICE: this differs from the above function! hasAlpha() does NOT refer to the alpha value that you can setAlpha(), but if the original image comes with an active alpha channel (like an icon etc.)
if you want a help on taking a decision about the canvas color, THIS is the proper function

bool KGLImageView::KGLImage::hasClipping  )  const [inline]
 

int KGLImageView::KGLImage::height  )  const
 

Returns the current onscreen pixelheight
NOTICE: This value changes as soon as the image or the view are translated on the Z axis, scaled or the view is resized.
You need to recall it if you need it after such operation.

void KGLImageView::KGLImage::hide bool  update = true  ) 
 

Set the image to be hidden

Parameters:
update Whether the View should be updated right after hiding the image, set to false in case you want to perform many operations on the image and present the user only the final state

uint KGLImageView::KGLImage::id  )  const [inline]
 

void KGLImageView::KGLImage::invert bool  inverted = true,
bool  update = true
 

bool KGLImageView::KGLImage::isInverted  )  [inline]
 

bool KGLImageView::KGLImage::isShown  )  const [inline]
 

Whether the image is shown

void KGLImageView::KGLImage::move float  xPercent,
float  yPercent,
float  zPercent,
bool  update = true
 

void KGLImageView::KGLImage::move Axis  a,
float  percent,
int  msecs = 0
 

void KGLImageView::KGLImage::moveTo float  xPercent,
float  yPercent,
float  zPercent,
bool  update = true
 

void KGLImageView::KGLImage::moveTo Axis  a,
float  percent,
int  msecs = 0
 

void KGLImageView::KGLImage::paint  )  [protected]
 

KGLImageViewer* KGLImageView::KGLImage::parent  )  const [inline]
 

float KGLImageView::KGLImage::position Axis  a  )  const [inline]
 

Returns the current position of the image on axis a
NOTICE: if the image is moved animated, this is NOT the final but allways the CURRENT!!! position

void KGLImageView::KGLImage::removeShader GLhandleARB  shader,
bool  relinkProgram = true,
bool  update = true
 

Removes a shader from the images pipeline

Parameters:
shader A shader to remove (if non existent nothing happens)
relinkProgram If you want to remove many shaders in a row, set this to false for any but the last one (performance issue)
update Whether to update the display after removing this shader (autoset to false if you're not linking, so removeShader(myFancyShader, false, true) will NOT update the display)

void KGLImageView::KGLImage::resize int  width,
int  height,
int  msecs = 0,
float  assumedViewScaleX = -1.0,
float  assumedViewScaleY = -1.0
 

void KGLImageView::KGLImage::rotate float  xDegrees,
float  yDegrees,
float  zDegrees,
bool  update = true
 

Rotate the image around all three axes (accumulating)
Keep in mind that this is a 3D environment. If you rotate around the X xor the Y axis by 180°, the rotation direction (CW/CCW) around the Z axis is swapped
NOTICE: the rotation happens in ADDITION to the VIEW rotation

Parameters:
xDegrees Rotation around the X axis (horizontal axis)
yDegrees Rotation around the Y axis (vertical axis)
zDegrees Rotation around the Z axis (2D rotation)
update Whether the screen should be updated after this action (set false in case you want to perform several translations to the view and this is not the last)

void KGLImageView::KGLImage::rotate Axis  a,
float  degrees,
int  msecs = 0
 

Rotate the image by some degrees (accumulating)
Keep in mind that this is a 3D environment. If you rotate around the X xor the Y axis by 180°, the rotation direction (CW/CCW) around the Z axis is swapped
NOTICE: the rotation happens in ADDITION to the VIEW rotation

Parameters:
a On which axis (use Z for a 2D rotation)
degrees How much. Values may be positive (CW) or negative (CCW). Rotates accumulative (new rotation = current rotation + degrees)
msecs How long the rotation shall last, the default is 0 - thus the new rotation is reached immediately. NOTICE: that rotation() will allways respond the current value, not the final value, while the rotation is active

void KGLImageView::KGLImage::rotateTo float  xDegrees,
float  yDegrees,
float  zDegrees,
bool  update = true
 

Rotate the image around all three axes (NOT accumulative)
Keep in mind that this is a 3D environment. If you rotate around the X xor the Y axis by 180°, the rotation direction (CW/CCW) around the Z axis is swapped
NOTICE: the rotation happens in ADDITION to the VIEW rotation

Parameters:
xDegrees Rotation around the X axis (horizontal axis)
yDegrees Rotation around the Y axis (vertical axis)
zDegrees Rotation around the Z axis (2D rotation)
update Whether the screen should be updated after this action (set false in case you want to perform several translations to the view and this is not the last)

void KGLImageView::KGLImage::rotateTo Axis  a,
float  degrees,
int  msecs = 0
 

Rotate the image to demanded degrees (NOT accumulative)
Keep in mind that this is a 3D environment. If you rotate around the X xor the Y axis by 180°, the rotation direction (CW/CCW) around the Z axis is swapped
NOTICE: the rotation happens in ADDITION to the VIEW rotation

Parameters:
a On which axis (use Z for a 2D rotation)
degrees How much. Values may be positive (CW) or negative (CCW). Rotates nonaccumulative (new rotation = degrees)
msecs How long the rotation shall last, the default is 0 - thus the new rotation is reached immediately. NOTICE: that rotation() will allways respond the current value, not the final value, while the rotation is active

float KGLImageView::KGLImage::rotation Axis  a  )  const [inline]
 

Returns the current rotation of the image (degrees, may be negative)
NOTICE: if the image is rotated animated, this is NOT the final but allways the CURRENT!!! rotation

void KGLImageView::KGLImage::scale float  xPercent,
float  yPercent,
bool  update = true
 

Scale the image along the X and Y axis by some percent (accumulating)
NOTICE: the scaling happens in ADDITION to the VIEW scale

Parameters:
yPercent 
xPercent How much. Values should be positive. Scales accumulative, i.e. if your view was previously scaled to 80% scale(X, 50%); will end up with a 40% scaled view
update Whether the screen should be updated after this action (set false in case you want to perform several translations to the view and this is not the last)

float KGLImageView::KGLImage::scale Axis  a,
float  percent,
int  msecs = 0
 

Scale the image by some percent (accumulating)
NOTICE: the scaling happens in ADDITION to the VIEW scale

Parameters:
a On which axis (use X or Y, Z is ignored as images don't have a third dimension)
percent How much. Values should be positive. Scales accumulative, i.e. if your view was previously scaled to 80% scale(X, 50%); will end up with a 40% scaled view
msecs How long the scaling shall last, the default is 0 - thus the new scale is reached immediately. NOTICE: that scacleFactor() will allways respond the current value, not the final value, while scaling is active

float KGLImageView::KGLImage::scaleFactor Axis  a  )  const [inline]
 

Returns the current scale of the image (percent, allways positive)
NOTICE: if the image is scaled animated, this is NOT the final but allways the CURRENT!!! scale

void KGLImageView::KGLImage::scaleTo float  xPercent,
float  yPercent,
bool  update = true,
bool  viewRelative = false,
float  assumedViewScaleX = -1.0,
float  assumedViewScaleY = -1.0
 

float KGLImageView::KGLImage::scaleTo Axis  a,
float  percent,
int  msecs = 0,
bool  viewRelative = false,
float  assumedViewScale = -1.0
 

Scale the image along given axis to some percent (NOT accumulating)
NOTICE: the scaling happens in ADDITION to the VIEW scale

Parameters:
a the Axis. Use X or Y, Z is ignored
percent The final scale factor.
msecs How long the scaling shall last, the default is 0 - thus the new scalefactor is reached immediately.
NOTICE: that scaleFactor() will allways respond the current value - not the final value - while the scaling is active
viewRelative 
assumedViewScale Assume you want to scale viewRelative and at the same time scale the view.

void KGLImageView::KGLImage::setAlpha float  percent,
int  msecs = 0
 

void KGLImageView::KGLImage::setBrightness float  percent,
int  msecs = 0
 

void KGLImageView::KGLImage::setClipping bool  enabled = true  )  [inline]
 

void KGLImageView::KGLImage::setClipRect QRect &  r,
bool  update = true
[inline]
 

void KGLImageView::KGLImage::setClipRect int  x,
int  y,
int  w,
int  h,
bool  update = true
 

void KGLImageView::KGLImage::setInternalColor const QColor  color  )  [inline]
 

Sets the internal color.
WANRNING: the internal color is updated as soon as KGLImageViewer::mergeCnB() is called. You probably only wnat to call this one if reimplementing KGLImageViewer::mergeCnB()

Parameters:
color the color to be set (rgb)

void KGLImageView::KGLImage::setShaderProgram KGLImage img  )  [inline]
 

Sets the images shader program to the program of another image WARNING: The two images will then share the same shader program and a modification on one will affect the other as well

Parameters:
img The KGLImage to share the shader program with

int KGLImageView::KGLImage::setShaderUniform QString  var,
const int  varSize,
const float  val1,
const float  val2 = 0.0,
const float  val3 = 0.0,
const float  val4 = 0.0
 

Overloaded for convenience - queries the id for the variable string and sets the variable value
Returns the variable identifier

void KGLImageView::KGLImage::setShaderUniform const int  var,
const int  varSize,
const float  val1,
const float  val2 = 0.0,
const float  val3 = 0.0,
const float  val4 = 0.0
 

Set a uniform variable you may need in your shader.
Attributes cannot be set, as it won't make any sense in this context (attributes are only necessary to set them between glBegin() and glEnd() - what you're usually not gonna do)

Parameters:
var the shader uniform variable ID (can be queried by calling the below overload at the first time)
varSize [1,4] whether you want to set float, vec2, vec3 or vec4
val1 the 1st value to be set
val2 the 2nd value to be set
val3 the 3rd value to be set
val4 the 4th value to be set

GLhandleARB KGLImageView::KGLImage::shaderProgram  )  [inline]
 

The shader program (collection of shaders) for this image (may be zero if no shader was added)

ShaderList& KGLImageView::KGLImage::shaders  )  [inline]
 

A QList containig all shaders that are atached to this image

void KGLImageView::KGLImage::show bool  update = true  ) 
 

Set the image to be shown

Parameters:
update Whether the View should be updated right after showing the image, set to false in case you want to perform many operations on the image and present the user only the final state
Example: you want to show the image, set the alpha value to zero and then fade it in:
 view.load("Some_image.png", false);
 view.images().last().setAlpha(0.0);
 view.images().last().show();
 view.images().last().setAlpha(100.0, 500);

void KGLImageView::KGLImage::tint const QColor &  color,
int  msecs = 0
 

void KGLImageView::KGLImage::tunnel float  factor,
int  msecs = 0
[inline]
 

See boxBlur()

int KGLImageView::KGLImage::width  )  const
 

Returns the current onscreen pixelwidth
NOTICE: This value changes as soon as the image or the view are translated on the Z axis, scaled or the view is resized.
You need to recall it if you need it after such operation.


Friends And Related Function Documentation

friend class KGLImageViewer [friend]
 


The documentation for this class was generated from the following file:
Generated on Fri Jul 28 22:36:13 2006 for KGlImageViewer by doxygen 1.3.3