mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-14 00:28:42 +00:00
R integration and Version in About
.. integration fixups for cross platform .. RInside will need to be built with callbacks enabled .. R Version is shown in about version
This commit is contained in:
49
src/Charts/RChart.h
Normal file
49
src/Charts/RChart.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2016 Mark Liversedge (liversedge@gmail.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 51
|
||||
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _GC_RChart_h
|
||||
#define _GC_RChart_h 1
|
||||
|
||||
#include <RInside.h>
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
#include <string.h>
|
||||
|
||||
class RCallbacks : public Callbacks {
|
||||
public:
|
||||
// see inst/includes/Callbacks.h for a list of all overrideable methods
|
||||
virtual void WriteConsole(const std::string& line, int type) {
|
||||
//qDebug()<<"Console>>" <<type<< QString::fromStdString(line);
|
||||
strings << QString::fromStdString(line);
|
||||
};
|
||||
|
||||
virtual void ShowMessage(const char* message) {
|
||||
//qDebug()<<"M:" << QString(message);
|
||||
strings << QString(message);
|
||||
}
|
||||
|
||||
virtual bool has_ShowMessage() { return true; }
|
||||
virtual bool has_WriteConsole() { return true; }
|
||||
|
||||
QStringList &getConsoleOutput() {
|
||||
return strings;
|
||||
}
|
||||
private:
|
||||
QStringList strings;
|
||||
};
|
||||
#endif
|
||||
@@ -74,7 +74,10 @@ HttpListener *listener = NULL;
|
||||
// R is not multithreaded, has a single instance that we setup at startup.
|
||||
#ifdef GC_WANT_R
|
||||
#include <RInside.h>
|
||||
#include <RChart.h> // for RCallback
|
||||
RInside *gc_RInside;
|
||||
RCallbacks *gc_RCallbacks;
|
||||
QString gc_RVersion;
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -269,6 +272,25 @@ main(int argc, char *argv[])
|
||||
// will be shared by all athletes and all charts (!!)
|
||||
RInside R(argc,argv);
|
||||
gc_RInside = &R;
|
||||
#if !defined(RINSIDE_CALLBACKS)
|
||||
#error "GC_WANT_R: RInside must have callbacks enabled (see inst/RInsideConfig.h)"
|
||||
#else
|
||||
gc_RCallbacks = new RCallbacks;
|
||||
gc_RInside->set_callbacks(gc_RCallbacks);
|
||||
|
||||
// lets get the version early for the about dialog
|
||||
gc_RInside->parseEvalNT("print(R.version.string)");
|
||||
QStringList &version = gc_RCallbacks->getConsoleOutput();
|
||||
if (version.count() == 3) {
|
||||
QRegExp exp("^.*\([0-9]+\.[0-9]+\.[0-9]+\).*$");
|
||||
if (exp.exactMatch(version[1])) gc_RVersion = exp.cap(1);
|
||||
else gc_RVersion = version[1];
|
||||
}
|
||||
version.clear();
|
||||
|
||||
#endif
|
||||
#else
|
||||
gc_RVersion = "none";
|
||||
#endif
|
||||
|
||||
// create the application -- only ever ONE regardless of restarts
|
||||
|
||||
@@ -313,6 +313,7 @@ QString GcCrashDialog::versionHTML()
|
||||
"<tr><td colspan=\"2\">VIDEO</td><td>%15</td></tr>"
|
||||
"<tr><td colspan=\"2\">SAMPLERATE</td><td>%16</td></tr>"
|
||||
"<tr><td colspan=\"2\">SSL</td><td>%17</td></tr>"
|
||||
"<tr><td colspan=\"2\">R</td><td>%18</td></tr>"
|
||||
"</table>"
|
||||
)
|
||||
.arg(QT_VERSION_STR)
|
||||
@@ -340,6 +341,7 @@ QString GcCrashDialog::versionHTML()
|
||||
#endif
|
||||
.arg(src)
|
||||
.arg(QSslSocket::supportsSsl() ? "yes" : "none")
|
||||
.arg(gc_RVersion)
|
||||
|
||||
;
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
|
||||
#include "Athlete.h"
|
||||
|
||||
// declared in main.cpp
|
||||
extern QString gc_RVersion;
|
||||
|
||||
class GcCrashDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -258,7 +258,9 @@ contains(DEFINES, "GC_WANT_R") {
|
||||
|
||||
## compiler etc settings used in default make rules
|
||||
QMAKE_CXXFLAGS += $$RCPPWARNING $$RCPPFLAGS $$RCPPINCL $$RINSIDEINCL
|
||||
LIBS += $$RLDFLAGS $$RBLAS $$RLAPACK $$RCPPLIBS $$RINSIDELIBS
|
||||
LIBS += $$RLDFLAGS $$RBLAS $$RLAPACK $$RCPPLIBS $$RINSIDELIBS
|
||||
|
||||
HEADERS += Charts/RChart.h
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user