[Zooimage-commits] r130 - pkg/zooimage/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu May 7 11:34:21 CEST 2009
Author: romain
Date: 2009-05-07 11:34:21 +0200 (Thu, 07 May 2009)
New Revision: 130
Modified:
pkg/zooimage/R/ZITrain.r
pkg/zooimage/R/gui.r
pkg/zooimage/R/programs.R
pkg/zooimage/R/zzz.r
Log:
fix makeTrain (files were not created at the right place)
Modified: pkg/zooimage/R/ZITrain.r
===================================================================
--- pkg/zooimage/R/ZITrain.r 2009-05-07 08:38:38 UTC (rev 129)
+++ pkg/zooimage/R/ZITrain.r 2009-05-07 09:34:21 UTC (rev 130)
@@ -51,30 +51,32 @@
check.zic( groups.template )
# Do the job...
- cat("Extracting data...\n")
- logProcess("\nExtracting data...")
+ cat("Extracting data and vignettes ...\n")
+ logProcess("\nExtracting data and vignettes ...")
zmax <- length(zidfiles)
- for (i in 1:zmax) {
- logProcess("data", zidfiles[i])
- Progress(i, zmax)
- unzip( zipfile = zidfiles[i] , path = dir, delete.source = FALSE )
- }
- ClearProgress()
- # Create '_' subdir and unzip all vignettes there
+ # C-reate '_' subdir and unzip all vignettes there
dir_ <- file.path(dir, "_")
force.dir.create( dir_ )
- # Do the job...
- cat("Extracting vignettes...\n")
- logProcess("\nExtracting vignettes...")
- zmax <- length(zidfiles)
+
for (i in 1:zmax) {
- logProcess("vignettes", zidfiles[i])
+ logProcess("data", zidfiles[i])
Progress(i, zmax)
-
- # Unzip vignettes (*.jpg files) there
- unzip( zidfiles[i], path = dir_, delete.source = FALSE )
-
+ # using a temporary directory to unzip all files and then copy
+ # the RData files to the train directory
+ td <- tempfile()
+ unzip( zipfile = zidfiles[i] , path = td, delete.source = FALSE )
+ datafiles <- file.path( td, list.files( td, pattern = extensionPattern(".RData"),
+ recursive = TRUE ) )
+ if( length(datafiles) ){
+ file.copy( datafiles, dir )
+ }
+ vignettes <- file.path( td, list.files( td, pattern = extensionPattern(".jpg"),
+ recursive = TRUE ) )
+ if(length( vignettes) ){
+ file.copy( vignettes, dir_ )
+ }
+ unlink(td, recursive = TRUE )
}
ClearProgress()
@@ -97,7 +99,7 @@
ok.log.msg = "\n-- Done! --" )
if (start.viewer) {
- startPgm("ImageViewer", cmdline = paste('"', dir_, '"', sep = ""))
+ imageViewer( dir_ )
}
return(invisible(TRUE))
}
Modified: pkg/zooimage/R/gui.r
===================================================================
--- pkg/zooimage/R/gui.r 2009-05-07 08:38:38 UTC (rev 129)
+++ pkg/zooimage/R/gui.r 2009-05-07 09:34:21 UTC (rev 130)
@@ -192,10 +192,13 @@
}
# Start it
system(paste(pgmPath, cmdline), wait = wait)
- } else stop("Program not found!")
+ } else {
+ stop(paste( "Program '",program,"' not found!") )
+ }
# Do we need to iconize the assistant?
- if (iconize && !is.null(WinGet("ZIDlgWin")))
+ if (iconize && !is.null(WinGet("ZIDlgWin"))){
tkwm.iconify(WinGet("ZIDlgWin"))
+ }
}
# }}}
@@ -506,8 +509,10 @@
"(3) a series of .zid files as source of vignettes.", "",
"Use the following grouping scheme:", ""), init = defval,
options = opts, help.topic = "makeTrain")
+
# Analyze result
if (res == "ID_CANCEL") return(invisible())
+
# Did we selected "Another config..."?
if (res == "Another config...") {
# Ask for selecting a .zic file containing the config
@@ -519,11 +524,14 @@
# Did we selected a standard scheme?
res <- paste("[", res, "]", sep = "")
} else res <- Grp # We should have selected the previously recorded scheme...
+
# Save this config for later use
setKey("DefaultGrouping", res)
+
# Ask for the base directory
dir <- paste(tkchooseDirectory(), collapse = " ")
if (length(dir) == 0) return(invisible())
+
# Ask for a subdir for this training set
subdir <- dialogString("Subdirectory where to create the training set:",
default = "_train")
@@ -531,16 +539,20 @@
cat("Operation cancelled!\n")
return(invisible())
}
+
# Ask for the .zid files
zidfiles <- selectFile(type = "Zid", multi = TRUE, quote = FALSE)
+
# Prepare the training set
prepare.ZITrain(dir, subdir, zidfiles, groups.template = res, start.viewer = TRUE)
+
# Remember the directory...
assignTemp("ZI.TrainDir", file.path(dir, subdir))
}
+#' Read a training set and create a ZITrain object
"readTrain" <- function() {
- # Read a training set and create a ZITrain object
+
(require(svDialogs) || stop("Package 'svDialogs' from 'SciViews' bundle is required. Please, install it first!"))
# Get a possibly saved directory as default one
Modified: pkg/zooimage/R/programs.R
===================================================================
--- pkg/zooimage/R/programs.R 2009-05-07 08:38:38 UTC (rev 129)
+++ pkg/zooimage/R/programs.R 2009-05-07 09:34:21 UTC (rev 130)
@@ -158,4 +158,17 @@
}
# }}}
+# {{{ imageViewer
+imageViewer <- function( dir = getwd() ){
+ if( isWin() ){
+ startPgm( "ImageViewer", sprintf( '"%s"', tools:::file_path_as_absolute(dir) ) )
+ } else{
+ # TODO: deal with mac
+ # TODO: maybe we should not rely on nautilus
+ cmd <- sprintf( 'nautilus --geometry 600x600 "%s"', dir )
+ system( cmd )
+ }
+}
+# }}}
+
# :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1:
Modified: pkg/zooimage/R/zzz.r
===================================================================
--- pkg/zooimage/R/zzz.r 2009-05-07 08:38:38 UTC (rev 129)
+++ pkg/zooimage/R/zzz.r 2009-05-07 09:34:21 UTC (rev 130)
@@ -134,6 +134,11 @@
if (file.exists(XnViewExe)){
options(ImageViewer = XnViewExe)
}
+ } else{
+ # TODO: deal with mac
+ # TODO: can we rely on nautilus ? it might not be installed on
+ # kde based distributions
+
}
# }}}
More information about the Zooimage-commits
mailing list