.. GC.activity(compare=TRUE) will return a list of compares
.. If you are not in compare mode it will be 1 element long
and represent the currently selected ride
.. otherwise it will have one entry for each activity dropped
into the compare pane
.. each element has a $activity and a $color
Example:
df <- GC.activity()
.. do plot ..
Now:
compares <- GC.activity(compare=TRUE)
for (compare in compares) {
df <- compare$activity
col <- compare$color
.. do plot ...
}
.. you can pass all=TRUE|FALSE to GC.metrics if you want to
override the date range selection
.. also added connect to daterange select so a trend chart
will refresh when you select a date range
.. set a script to run when an activity is selected
.. this allows a plot to be generated and displayed when
you select a ride in analysis view
.. the script is stored with the chart settings
.. it now builds and runs on Windows
.. there is a runtime crash when embedded R is initialised
that needs to be reolved
** NOTE **
R is not distributed with a .lib that can be linked to
with the MS VC linker. Instead, we need to generate a
lib and exp file from the dll:
1. dumpbin /exports R.dll > R.def
2. edit the .def output to have EXPORTS at the top and
a list of functions only (last column, delete the rest)
3. lib /machine:x64 /def:R.def
After linking remember to copy the DLLs to the GoldenCheetah
build directory from the $R_HOME/bin/x64/*.dll
.. and a few more tidy ups.
.. never cease to be amazed at how some developers
will feel its OK to define generic symbols like
TRUE and FALSE in their code (!!)
.. R is a mess.
.. mostly startup issues when R_HOME is not known
.. need to think carefully about how we get the user to
register the R home. We could let them select the R
binary so we can run `R RHOME` and apply that (?)
.. we no longer need RInside or Rcpp as we use
100% R API calls to embed
.. the following need to be resolved:
1. R_HOME / Options *must* be set to startup
embedded R but we don't check / restart or
default via system("R HOME")
2. Output is not trapped - all output is sent
directly to the console you started GC on
.. will fixup the 2 above before finally:
3. Build for Windows using MSVC !
.. we can register routines when embedding via the
R_getEmbeddingDLLInfo()
.. so we just register our functions directly now
in RTool rather than needing a dynamic library.
.. its cleaner and there are no nasty casts and build
settings required
.. reimplemented with native R API
.. switched to .Call in R function since .C means all functions
return void and must return by a pass by reference parameter.
.. its not needed as the workaround of using an extern "C" function
to perform the function pointer cast conforms to standard.
.. this just simplifies src.pro that was getting heavy
.. fixup R SHLIB build and integration to work on OSX
**** WARNING ****
If you build for OSX with GC_WANT_R You will need to
manually copy RGoldenCheetah.so into the app bundle.
$ cp RGoldenCheetah.so ./GoldenCheetah.app/Contents/MacOS
*****************
.. phew. that was hard.
.. To register routines with R you need to place them in a shared
library.
.. The routines we want to register are part of the GC codebase so
cannot be linked into that shared library (it would be the whole
of GC).
.. So; we have a shared library (RGoldenCheetah.cpp) which has stubs
for all the registered functions and an array of pointers to the
actual functions.
.. We load the library (once R is embedded it is loaded in main.cpp)
.. After the library is loaded we then call one of its public
functions (GCInitialiseFunctions) to tell it where all the GC
functions are (we only have GCdisplay at present for this proof
of the concept).
.. Along the way we need to deref/cast DL_FUNC in RTool.cpp which
is not permitted in ISO C, so we also update qmake to add a
special rule to compile `dodgy' sources with -fpermissive. And
the only dodgy source is RTool.cpp.
.. This commmit will break GC_WANT_R builds on OSX, and will be
fixed up shortly.
.. The motivation behind this is to avoid RInside/Rcpp for Windows
builds -- enabling R support (which is not currently possible).