Svg Class Reference
from PyKDE4.plasma import *
Inherits: QObject
Subclasses: Plasma.FrameSvg
Namespace: Plasma
Detailed Description
Svg plasma/svg.h <Plasma/Svg>
A theme aware image-centric SVG class
Plasma.Svg provides a class for rendering SVG images to a QPainter in a convenient manner. Unless an absolute path to a file is provided, it loads the SVG document using Plasma.Theme. It also provides a number of internal optimizations to help lower the cost of painting SVGs, such as caching.
- See also:
- Plasma.FrameSvg
Signals | |
repaintNeeded () | |
Methods | |
__init__ (self, QObject parent=0) | |
bool | containsMultipleImages (self) |
QString | elementAtPoint (self, QPoint point) |
QRectF | elementRect (self, QString elementId) |
QSize | elementSize (self, QString elementId) |
bool | hasElement (self, QString elementId) |
QString | imagePath (self) |
bool | isUsingRenderingCache (self) |
bool | isValid (self) |
paint (self, QPainter painter, QPointF point, QString elementID=QString()) | |
paint (self, QPainter painter, int x, int y, QString elementID=QString()) | |
paint (self, QPainter painter, QRectF rect, QString elementID=QString()) | |
paint (self, QPainter painter, int x, int y, int width, int height, QString elementID=QString()) | |
QPixmap | pixmap (self, QString elementID=QString()) |
repaintNeeded (self) | |
resize (self, float width, float height) | |
resize (self, QSizeF size) | |
resize (self) | |
setContainsMultipleImages (self, bool multiple) | |
setImagePath (self, QString svgFilePath) | |
setTheme (self, Plasma.Theme theme) | |
setUsingRenderingCache (self, bool useCache) | |
QSize | size (self) |
Plasma.Theme | theme (self) |
Method Documentation
__init__ | ( | self, | ||
QObject | parent=0 | |||
) |
Constructs an SVG object that implicitly shares and caches rendering As opposed to QSvgRenderer, which this class uses internally, Plasma.Svg represents an image generated from an SVG. As such, it has a related size and transform matrix (the latter being provided by the painter used to paint the image).
The size is initialized to be the SVG's native size.
@arg parent options QObject to parent this to
@related Plasma.Theme
bool containsMultipleImages | ( | self ) |
- Returns:
- whether or not the svg contains multiple images or not
Returns the element (by id) at the given point. An empty string is returned if no element is at that point.
The bounding rect of a given element @arg elementId the id of the element to check
- Returns:
- the current rect of a given element, given the current size of the Svg
Size of a given element @arg elementId the id of the element to check
- Returns:
- the current size of a given element, given the current size of the Svg
bool hasElement | ( | self, | ||
QString | elementId | |||
) |
Check when an element exists in the loaded Svg @arg elementId the id of the element to check
- Returns:
- true if the element is defined in the Svg, otherwise false
QString imagePath | ( | self ) |
Convenience method to get the svg filepath and name of svg.
- Returns:
- the svg's filepath including name of the svg.
bool isUsingRenderingCache | ( | self ) |
- Returns:
- true if the Svg is using caching for rendering results
- Since:
- 4.3
bool isValid | ( | self ) |
- Returns:
- true if the SVG file exists and the document is valid, otherwise false. This method can be expensive as it causes disk access.
Paints the SVG represented by this object @arg painter the QPainter to use @arg point the position to start drawing; the entire svg will be drawn starting at this point. @arg elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)
Paints the SVG represented by this object @arg painter the QPainter to use @arg x the horizontal coordinate to start painting from @arg y the vertical coordinate to start painting from @arg elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)
Paints the SVG represented by this object @arg painter the QPainter to use @arg rect the rect to draw into; if smaller than the current size the drawing is starting at this point. @arg elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)
Paints the SVG represented by this object @arg painter the QPainter to use @arg x the horizontal coordinate to start painting from @arg y the vertical coordinate to start painting from @arg width the width of the element to draw @arg height the height of the element do draw @arg elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)
Returns a pixmap of the SVG represented by this object.
@arg elelementId the ID string of the element to render, or an empty string for the whole SVG (the default)
- Returns:
- a QPixmap of the rendered SVG
repaintNeeded | ( | self ) |
- Signal syntax:
QObject.connect(source, SIGNAL("repaintNeeded()"), target_slot)
resize | ( | self, | ||
float | width, | |||
float | height | |||
) |
Resizes the rendered image. Rendering will actually take place on the next call to paint. @arg width the new width @arg height the new height
resize | ( | self, | ||
QSizeF | size | |||
) |
Resizes the rendered image. Rendering will actually take place on the next call to paint. @arg size the new size of the image
resize | ( | self ) |
Resizes the rendered image to the natural size of the SVG. Rendering will actually take place on the next call to paint.
setContainsMultipleImages | ( | self, | ||
bool | multiple | |||
) |
Set if the svg contains a single image or multiple ones. @arg multiple true if the svg contains multiple images
setImagePath | ( | self, | ||
QString | svgFilePath | |||
) |
Convenience method for setting the svg file to use for the Svg. @arg svgFilePath the filepath including name of the svg.
setTheme | ( | self, | ||
Plasma.Theme | theme | |||
) |
Sets the Plasma.Theme to use with this Svg object. By default, Svg objects use Plasma.Theme.default() @arg theme the theme object to use
- Since:
- 4.3
setUsingRenderingCache | ( | self, | ||
bool | useCache | |||
) |
Sets whether or not to cache the results of rendering to pixmaps. If the Svg is resized and re-rendered often without pattern to the resulting pixmap dimensions, then it may be less efficient to do disk caching. A good example might be a progress meter that uses an Svg object to paint itself: the meter will be changing often enoughi, with enough unpredictability and without re-use of the previous pixmaps to not get a gain from caching.
Most Svg objects should use the caching feature, however. Therefore, the default is to use the render cache.
- Parameters:
-
useCache true to cache rendered pixmaps
- Since:
- 4.3
QSize size | ( | self ) |
Currently set size of the SVG
- Returns:
- the current size of the SVG
Plasma.Theme theme | ( | self ) |
- Returns:
- the theme used by this Svg