Skip to content

Commit

Permalink
Merge pull request #305 from iNZightVIT/release/3.5.3
Browse files Browse the repository at this point in the history
Release/3.5.3
  • Loading branch information
tmelliott committed May 11, 2020
2 parents d51f869 + bd5a222 commit 30f5d4d
Show file tree
Hide file tree
Showing 19 changed files with 850 additions and 231 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Expand Up @@ -14,6 +14,8 @@ services:

matrix:
include:
- os: linux
r: oldrel
- os: linux
r: release
- os: linux
Expand All @@ -28,11 +30,12 @@ repos:
docker: https://r.docker.stat.auckland.ac.nz

r_github_packages:
- iNZightVIT/iNZightTools@1.8.4
- iNZightVIT/iNZightTS
- iNZightVIT/iNZightMR
- iNZightVIT/iNZightPlots@2.11.1
- iNZightVIT/iNZightModules@2.4.9
- iNZightVIT/gWidgets2RGtk2@inz
- iNZightVIT/iNZightTools@dev
- iNZightVIT/iNZightTS@dev
- iNZightVIT/iNZightMR@dev
- iNZightVIT/iNZightPlots@dev
- iNZightVIT/iNZightModules@dev

addons:
apt:
Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: iNZight
Type: Package
Title: iNZight GUI for Data Exploration and Visualisation
Version: 3.5.2
Date: 2020-04-20
Version: 3.5.3
Date: 2020-05-11
Authors@R: c(person("Tom", "Elliott", role = c("aut", "cre"),
email = "tom.elliott@auckland.ac.nz"),
person("Dineika", "Chandrananda", role = "ctb"),
Expand Down Expand Up @@ -37,7 +37,7 @@ Imports:
Suggests:
RODBC,
iNZightMR (>= 2.2.4),
iNZightModules (>= 2.4.9),
iNZightModules (>= 2.5),
png,
viridis,
RColorBrewer,
Expand All @@ -51,4 +51,5 @@ Suggests:
Additional_repositories: https://r.docker.stat.auckland.ac.nz
LazyData: true
Encoding: UTF-8
Language: en-GB
RoxygenNote: 7.1.0
13 changes: 10 additions & 3 deletions NEWS.Md
@@ -1,19 +1,26 @@
# iNZight 3.5.2
## iNZight 3.5.3
- New Module Manager
- Beta functionality: save and load the iNZight session. Accessible by first going to File > Preferences and turning on developmental features (requires restart).
- pass NULL to scale/rscale when specifying survey replicate design
type that does not ask user for them
- fix function name from iNZightPlots

## iNZight 3.5.2
- move makeNames() method (part of iNZDataModWin) to 'iNZightTools' package
as iNZightTools::make_names()
- specify `stringsAsFactors = TRUE` for upcoming R 4.0.0
- manage modules from the Advanced menu
- pass colby and locate variable to interactive plot

## iNZight 3.5.0
## iNZight 3.5.1

- load from clipboard option
- add option to import data from a URL as well as local files
- remove equal variance checkbox for survey design (two way t-test)
- survey design code pasted together with a new line when `deparse` returns multiple lines (#281, @tmelliott)


## iNZight 3.5
# iNZight 3.5
__Release date__: 11 November 2019

- allow users to change column types for all import types (cat/num)
Expand Down
3 changes: 1 addition & 2 deletions R/iNZDocument.R
Expand Up @@ -208,8 +208,7 @@ iNZDataModel <- setRefClass(
)
)
}

eval(obj)
suppressWarnings(eval(obj))
},
getDesign = function() {
dataDesign
Expand Down
243 changes: 218 additions & 25 deletions R/iNZGUI.R
Expand Up @@ -95,13 +95,24 @@ iNZGUI <- setRefClass(
else if (Sys.info()["sysname"] == "Darwin") "mac"
else "linux"

# cat(getwd(), "\n")
# cat(path.expand(file.path("~", "iNZightVIT")), "\n")

# cat(dir.exists(path.expand("~")), "\n")
# cat(list.files(path.expand("~")), sep = "\n", "\n")

# cat("\n", Sys.getenv("R_USER"), "\n")


## We must set the correct directory correctly ...
switch(
OS,
"windows" = {
done <- FALSE
if (file.exists(file.path("~", "iNZightVIT"))) {
setwd(file.path("~", "iNZightVIT"))
} else if (file.exists(file.path("~", "Documents", "iNZightVIT"))) {
setwd(file.path("~", "Documents", "iNZightVIT"))
} else {
## Create it:
conf <- gconfirm(
Expand Down Expand Up @@ -1074,23 +1085,118 @@ iNZGUI <- setRefClass(
curPlSet$data_name <- dataNameWidget$datName

## Suppress the warnings produced by iNZightPlot ...
suppressWarnings({
## Generate the plot ... and update the interaction button
curPlot <<- unclass(rawpl <- do.call(iNZightPlot, curPlSet))
if (allow.redraw & !is.null(attr(curPlot, "dotplot.redraw")))
if (attr(curPlot, "dotplot.redraw"))
curPlot <<- unclass(rawpl <- do.call(iNZightPlot, curPlSet))
enabled(plotToolbar$exportplotBtn) <<- can.interact(rawpl)
})
dop <- try({
# suppressWarnings({
## Generate the plot ... and update the interaction button
curPlot <<- unclass(rawpl <- do.call(iNZightPlot, curPlSet))
if (allow.redraw & !is.null(attr(curPlot, "dotplot.redraw")))
if (attr(curPlot, "dotplot.redraw"))
curPlot <<- unclass(rawpl <- do.call(iNZightPlot, curPlSet))

# })
}, silent = TRUE)

if (inherits(dop, "try-error")) {
## Oops!

message("Call: ")
message(attr(dop, "condition")$call)
message("\nMessage: ")
message(attr(dop, "condition")$message)

n_max <- 4
err_call <- capture.output(attr(dop, "condition")$call)
if (length(err_call) > n_max) {
err_call <- c(
err_call[1:n_max],
sprintf("+ %i more lines (printed to R console)",
length(err_call) - n_max
)
)
}
err_msg <- capture.output(cat(attr(dop, "condition")$message))
if (length(err_msg) > n_max) {
err_msg <- c(
err_msg[1:n_max],
sprintf("+ %i more lines (printed to R console)",
length(err_msg) - n_max
)
)
}
plotMessage(
heading = "Oops ... that plot isn't working!",
message = paste(
"Call: \n",
paste(collapse = "\n ", err_call),
"\n\nError: \n",
paste(collapse = "\n ", err_msg)
),
footer = paste(sep = "\n",
"If you continue to experience this problem, please send a bug report to",
"inzight_support@stat.auckland.ac.nz including",
"- a screenshot of the current window",
"- a copy of the contents of the R Console",
"- a copy of the data (if possible)"
)
)
return(invisible(NULL))
}

enabled(plotToolbar$exportplotBtn) <<- can.interact(rawpl)
plotType <<- attr(curPlot, "plottype")
} else {
rawpl <- plotSplashScreen()
curPlot <<- NULL
plotType <<- "none"
enabled(plotToolbar$exportplotBtn) <<- FALSE
return(invisible(rawpl))
}

# only runs if unsuccessful
rawpl <- plotSplashScreen()
curPlot <<- NULL
plotType <<- "none"
enabled(plotToolbar$exportplotBtn) <<- FALSE
invisible(rawpl)
},
saveState = function(file) {
state <- lapply(
seq_along(iNZDocuments),
function(i) {
list(
document = iNZDocuments[[i]],
plot_settings = iNZDocuments[[i]]$getSettings()
)
}
)
save(state, file = file)
},
loadState = function(file, .alert = TRUE) {
if (!file.exists(file)) {
if (.alert)
gmessage("File doesn't exist", icon = "error")
return()
}

e <- new.env()
load(file, envir = e)
if (is.null(e$state)) {
if (.alert)
gmessage("That file doesn't seem to be a valid iNZight save.",
icon = "error"
)
return()
}

setState(e$state)
},
setState = function(state) {
lapply(
state,
function(doc) {
setDocument(doc$document)
Sys.sleep(0.2)
getActiveDoc()$setSettings(doc$plot_settings, reset = TRUE)
ctrlWidget$setState(doc$plot_settings)
}
)
invisible(NULL)
},
## set a new iNZDocument and make it the active one
setDocument = function(document, reset = FALSE) {
if (reset) {
Expand Down Expand Up @@ -1329,29 +1435,26 @@ iNZGUI <- setRefClass(
defaultPrefs = function() {
## The default iNZight settings:
list(
track = "ask",
track.id = NULL,
check.updates = TRUE,
window.size = c(1250, 850),
popout = FALSE,
font.size = 10
font.size = 10,
dev.features = FALSE
)
},
checkPrefs = function(prefs) {
allowed.names <- c("track", "track.id", "check.updates",
"window.size", "popout", "font.size")
allowed.names <- c(
"check.updates",
"window.size",
"popout",
"font.size",
"dev.features"
)

## Only keep allowed preferences --- anything else is discarded
prefs <- prefs[names(prefs) %in% allowed.names]
defs <- defaultPrefs()

## TRACK = TRUE | FALSE | "ask"
prefs$track <-
if (is.null(prefs$track)) defs$track
else if (!is.na(prefs$track) & (prefs$track == "ask" | is.logical(prefs$track))) prefs$track
else defs$track


## check.updates = TRUE | FALSE
prefs$check.updates <-
if (is.null(prefs$check.updates)) defs$check.updates
Expand All @@ -1376,6 +1479,10 @@ iNZGUI <- setRefClass(
if (is.null(prefs$font.size) || !is_num(prefs$font.size)) defs$font.size
else prefs$font.size

prefs$dev.features <-
if (is.null(prefs$dev.features) || !is.logical(prefs$dev.features)) defs$dev.features
else prefs$dev.features

prefs

},
Expand Down Expand Up @@ -1455,6 +1562,92 @@ iNZGUI <- setRefClass(
)
}
},
plotMessage = function(heading, message, footer) {
curPlot <<- NULL
plotType <<- "none"
enabled(plotToolbar$exportplotBtn) <<- FALSE

if (missing(heading) || missing(message))
plotSplashScreen()

grid::grid.newpage()
grid::pushViewport(
grid::viewport(
height = unit(0.9, "npc"),
layout = grid::grid.layout(
nrow = 3,
ncol = 1,
heights = unit.c(
unit(0.1, "npc"),
unit(1, "null"),
unit(5, "lines")
)
)
)
)

if (requireNamespace("png", quietly = TRUE)) {
img <- png::readPNG(
system.file("images/inzight_transp.png", package = "iNZight")
)
grid::pushViewport(grid::viewport(layout.pos.row = 1))
grid::grid.raster(img,
x = unit(0.1, "npc"),
y = unit(1, "npc"),
hjust = 0, vjust = 1
)
grid::upViewport()
}

grid::pushViewport(grid::viewport(layout.pos.row = 2))
grid::pushViewport(
grid::viewport(
y = unit(0.45, "npc"),
width = unit(0.8, "npc"),
height = unit(0.9, "npc")
)
)
grid::grid.text(
heading,
y = 1, x = 0, just = c("left", "top"),
gp = gpar(fontsize = 12, fontface = 'bold')
)

grid::grid.text(
paste0(
"The following error message was reported:"
),
y = unit(1, "npc") - unit(3, "lines"),
x = 0, just = c("left", "top"),
gp = gpar(fontsize = 11)
)
grid::grid.text(
message,
y = unit(1, "npc") - unit(6, "lines"),
x = 0, just = c("left", "top"),
gp = gpar(fontsize = 10, fontfamily = "monospace")
)
grid::upViewport()

if (!missing(footer)) {
grid::pushViewport(grid::viewport(layout.pos.row = 3))
grid::pushViewport(
grid::viewport(
y = unit(0.45, "npc"),
width = unit(0.8, "npc"),
height = unit(0.9, "npc")
)
)
grid::grid.text(
footer,
y = 0, x = 0, just = c("left", "bottom"),
gp = gpar(fontsize = 10)
)
grid::upViewport()
}

grDevices::dev.flush()
},
plotSplashScreen = function() {
if (requireNamespace("png", quietly = TRUE)) {
img <- png::readPNG(
Expand Down

0 comments on commit 30f5d4d

Please sign in to comment.