Description Usage Arguments Details Value Author(s) Examples
This function constructs a Layer, an item in the canvas that may paint part of the plot and/or respond to user input. The behavior of the layer is implemented using R functions, which are passed to the constructor. Other arguments determine the scaling and positioning of the layer, and whether the drawing of the layer is cached and/or clipped.
1 2 3 4 5 6 7 8 9 10 11 | qlayer(parent=NULL, paintFun=NULL, keyPressFun=NULL,
keyReleaseFun=NULL, mouseDoubleClickFun=NULL,
mouseMoveFun=NULL, mousePressFun=NULL,
mouseReleaseFun=NULL, wheelFun=NULL,
hoverMoveFun=NULL, hoverEnterFun=NULL, hoverLeaveFun=NULL,
contextMenuFun=NULL, dragEnterFun=NULL, dragLeaveFun=NULL,
dragMoveFun=NULL, dropFun=NULL, focusInFun=NULL,
focusOutFun=NULL, sizeHintFun=NULL, limits=qrect(),
row=0, col=0, rowSpan=1,
colSpan=1, geometry=defaultLayerGeometry(parent),
clip=cache, cache=FALSE)
|
parent |
The scene, for a top-level layer, or the parent layer that contains the new layer in a grid layout |
paintFun |
The function that implements painting, called whenever the layer needs to be repainted. All drawing occurs in data/layer coordinates. |
keyPressFun |
The function called when a key is pressed |
keyReleaseFun |
The function called when a key is released |
mouseDoubleClickFun |
The function called when a mouse button is double-clicked |
mouseMoveFun |
The function called when the mouse is moved while holding down a button |
mousePressFun |
The function called when a mouse button is pressed |
mouseReleaseFun |
The function called when a mouse button is released |
wheelFun |
The function called when the mouse wheel is turned |
hoverMoveFun |
The function called when the mouse moves without any buttons pressed |
hoverEnterFun |
The function called when the mouse pointer enters the layer |
hoverLeaveFun |
The function called when the mouse pointer leaves the layer |
contextMenuFun |
The function called when a context menu is requested, such as through a right mouse button click |
dragEnterFun |
The function called when the pointer enters the layer while dragging something |
dragLeaveFun |
The function called when the pointer leaves the layer while dragging something |
dragMoveFun |
The function called when the pointer moves within the layer while dragging something |
dropFun |
The function called when something is dropped on the layer |
focusInFun |
The function called when the layer gains the keyboard focus |
focusOutFun |
The function called when the layer loses the keyboard focus |
sizeHintFun |
The function called to determine the size constraints of the layer. Not currently documented. |
limits |
A |
row |
The 0-based row index of the layer in the parent grid layout |
col |
The 0-based column index of the layer in the parent grid layout |
rowSpan |
The 0-based number of rows spanned by the layer in the layout |
colSpan |
The 0-based number of cols spanned by the layer in the layout |
geometry |
A |
clip |
Logical indicating whether to clip drawing to within the layer |
cache |
Logical indicating whether to cache drawing, which helps performance for relatively static layers sitting under more dynamic ones |
All drawing and user input handling is performed by R callbacks,
which must accept a specific set of arguments. The paint callback,
passed as paintFun
, must take at least two arguments,
conventionally named layer
and painter
. The
layer
argument is a C++ RLayer
object, the same
instance that was created by calling the constructor. All painting
is performed through the painter
argument, which is a C++
Painter
object. See the paint functions
for more details. The paintFun
may take one additional, optional
argument, conventionally named exposed
, which is the rectangle,
in layer coordinates, that needs to be drawn.
All of the other callbacks, except for sizeHintFun
, are
event handlers. Two arguments are passed, conventionally named
layer
and event
. The former is the layer constructed
in the call to qlayer
, and the latter describes the event
as an instance of C++ QGraphicsSceneEvent
. The exact
subclass depends on the event. Manipulating an event currently
requires low-level calls through the qtbase
package. See
its documentation.
The layer, a C++ instance of RLayer
Michael Lawrence
1 2 3 4 5 | scene <- qscene()
layer <- qlayer(scene, function(layer, painter) {
qdrawCircle(painter, 1:10, 1:10, 1)
}, limits = qtbase::qrect(0, 0, 11, 11))
qplotView(scene)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.