simplepanel: Simple Point-and-Click Interface Panels

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/simplepanel.R

Description

These functions enable the user to create a simple, robust, point-and-click interface to any R code.

Usage

1
2
3
4
5
   simplepanel(title, B, boxes, clicks,
      redraws=NULL, exit = NULL, env)

   grow.simplepanel(P, side = c("right", "left", "top", "bottom"),
      len = NULL, new.clicks, new.redraws=NULL, ..., aspect)

Arguments

title

Character string giving the title of the interface panel.

B

Bounding box of the panel coordinates. A rectangular window (object of class "owin")

boxes

A list of rectangular windows (objects of class "owin") specifying the placement of the buttons and other interactive components of the panel.

clicks

A list of R functions, of the same length as boxes, specifying the operations to be performed when each button is clicked. Entries can also be NULL indicating that no action should occur. See Details.

redraws

Optional list of R functions, of the same length as boxes, specifying how to redraw each button. Entries can also be NULL indicating a simple default. See Details.

exit

An R function specifying actions to be taken when the interactive panel terminates.

env

An environment that will be passed as an argument to all the functions in clicks, redraws and exit.

P

An existing interaction panel (object of class "simplepanel").

side

Character string identifying which side of the panel P should be grown to accommodate the new buttons.

len

Optional. Thickness of the new panel area that should be grown to accommodate the new buttons. A single number in the same units as the coordinate system of P.

new.clicks

List of R functions defining the operations to be performed when each of the new buttons is clicked.

new.redraws

Optional. List of R functions, of the same length as new.clicks, defining how to redraw each of the new buttons.

...

Arguments passed to layout.boxes to determine the layout of the new buttons.

aspect

Optional. Aspect ratio (height/width) of the new buttons.

Details

These functions enable the user to create a simple, robust, point-and-click interface to any R code.

The functions simplepanel and grow.simplepanel create an object of class "simplepanel". Such an object defines the graphics to be displayed and the actions to be performed when the user interacts with the panel.

The panel is activated by calling run.simplepanel.

The function simplepanel creates a panel object from basic data. The function grow.simplepanel modifies an existing panel object P by growing an additional row or column of buttons.

For simplepanel,

For grow.simplepanel,

Value

An object of class "simplepanel".

Author(s)

\spatstatAuthors

.

See Also

run.simplepanel, layout.boxes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  # make boxes (alternatively use layout.boxes())
  Bminus <- square(1)
  Bvalue <- shift(Bminus, c(1.2, 0))
  Bplus <- shift(Bvalue, c(1.2, 0))
  Bdone <- shift(Bplus, c(1.2, 0))
  myboxes <- list(Bminus, Bvalue, Bplus, Bdone)
  myB <- do.call(boundingbox,myboxes)

  # make environment containing an integer count
  myenv <- new.env()
  assign("answer", 0, envir=myenv)

  # what to do when finished: return the count.
  myexit <- function(e) { return(get("answer", envir=e)) }

  # button clicks
  # decrement the count
  Cminus <- function(e, xy) {
    ans <- get("answer", envir=e)
    assign("answer", ans - 1, envir=e)
    return(TRUE)
  }
  # display the count (clicking does nothing)
  Cvalue <- function(...) { TRUE }
  # increment the count
  Cplus <- function(e, xy) {
    ans <- get("answer", envir=e)
    assign("answer", ans + 1, envir=e)
    return(TRUE)
  }
  # 'Clear' button
  Cclear <- function(e, xy) {
    assign("answer", 0, envir=e)
    return(TRUE)
  }
  # quit button
  Cdone <- function(e, xy) { return(FALSE) }

  myclicks <- list("-"=Cminus,
                   value=Cvalue,
                   "+"=Cplus,
                   done=Cdone)

  # redraw the button that displays the current value of the count
  Rvalue <- function(button, nam, e) {
     plot(button, add=TRUE)
     ans <- get("answer", envir=e)
     text(centroid.owin(button), labels=ans)
     return(TRUE)
  }

  # make the panel
  P <- simplepanel("Counter",
                   B=myB, boxes=myboxes,
                   clicks=myclicks,
                   redraws = list(NULL, Rvalue, NULL, NULL),
                   exit=myexit, env=myenv)
  # print it
  P
  # show what it looks like
  redraw.simplepanel(P)

  # ( type run.simplepanel(P) to run the panel interactively )

  # add another button to right
  Pplus <- grow.simplepanel(P, "right", new.clicks=list(clear=Cclear))

spatstat.geom documentation built on April 15, 2021, 9:06 a.m.