Skip to content

Commit

Permalink
Use view instead of plot
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed Nov 15, 2024
1 parent 5e6c41e commit c3745fd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(plot_xyzrgb)
exportMethods(plot)
export(view)
importClassesFrom(lidR,LAS)
importFrom(Rcpp,evalCpp)
useDynLib(lidRviewer, .registration = TRUE)
6 changes: 2 additions & 4 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
#' - Keyboard <kbd>l</kbd> to enable/disable eyes-dome lightning
#'
#' @param x a point cloud with minimally 3 columns named X,Y,Z
#' @param y Unused (inherited from R base)
#' @param ... Support detach = TRUE
#' @export
#' @method plot LAS
#' @importClassesFrom lidR LAS
#' @useDynLib lidRviewer, .registration = TRUE
#' @importFrom Rcpp evalCpp
#' @md
setMethod("plot", signature(x = "LAS", y = "missing"), function(x, y, ...)
view = function(x, ...)
{
p = list(...)
detach = isTRUE(p$detach)
viewer(x@data, detach, "")
})
}

render = function(f)
{
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ While `rgl` is a powerful package, it has some limitations when it comes to hand
### Advantages of `lidRviewer`:

* Capable of handling hundred millions of points efficiently if they fits in memory, unlike `rgl`, which may struggle with a few million.
* More memory efficient: it requires only a small amount of additional memory, whereas `rgl` may need gigabytes to store a full copy of the point cloud.
* More memory efficient: it requires less additional memory than `rgl` that may require gigabytes to store a full copy of the point cloud.
* Provides keyboard controls for changing coloring attributes and point size on-the-fly.
* Features eyes-dome lighting for better visualization.

Expand All @@ -28,14 +28,13 @@ devtools::install_github("lidRviewer", repos = 'https://r-lidar.r-universe.dev')

## Usage

Use `library(lidRviewer)` after `library(lidR)`to overide the default `rgl` plot function from `lidR`.

```r
library(lidR)
library(lidRviewer)
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las <- readLAS(LASfile)
plot(las)
view(las)
# Close the view to continue working in your R session
```

- Rotate with left mouse button
Expand Down
10 changes: 4 additions & 6 deletions man/plot-LAS-missing-method.Rd → man/view.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/lidRviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,12 @@ void sdl_loop(DataFrame df, std::string hnof)
break;
case SDLK_PLUS:
case SDLK_KP_PLUS:
case SDLK_p:
drawer->point_size_plus();
break;
case SDLK_MINUS:
case SDLK_KP_MINUS:
case SDLK_m:
drawer->point_size_minus();
break;
break;
Expand Down

0 comments on commit c3745fd

Please sign in to comment.