Commit Graph

22 Commits

Author SHA1 Message Date
Alejandro Martinez
a3e23fd6de Enabled compare for Python activiyMetrics
activityMetrics(True) returns a list of 2 element tuples with
metrics&metadata dict as first element and color name as second one.
2017-12-12 21:29:39 -03:00
Alejandro Martinez
da6db1eb6b Add Date and Time to Python activityMetrics
PyDateTime_IMPORT needs to be called in the same module where
datetime macros are used to avoid a crash.
2017-12-12 13:52:18 -03:00
Alejandro Martinez
a15bcfc102 Python activityMetrics
Returns a Python dict with metrics and metadata fields.
It doesn't implement compare mode yet.
2017-12-12 08:35:06 -03:00
Mark Liversedge
dd112d6d81 Python Webpage load via slots
.. to communicated across threads and avoid a crash.
2017-12-11 21:17:34 +00:00
Mark Liversedge
7eb926b33a Python Web Display
.. instead of an opengl canvas lets start with a Web canvas.

.. we might have options to use QtCharts or OpenGL later.

.. not working - committed to save WIP.
2017-12-11 18:58:59 +00:00
Mark Liversedge
a7981ff302 Python fixup ConvertTo_QString
.. missing in original code. will be needed for APIs that
   want to pass names etc to C++ from Python.
2017-12-11 12:32:33 +00:00
slorenz
80e786c4c0 Python Use UTF8 and untranslated Series Names
.. With german translation activated GC.activity() complains about
   some utf-8 decoding stuff and returns error.

   First I thought came from the real activity json file, but it's
   from translation: Altitude -> Höhenmeter.

   Is it necessary to use toLatin1() in goldencheetah.sip? With
   toUtf8() it works and you get delta symbols instead of question marks.

.. With R the series names are always in english and use a naming
   convention derived from the R trackR package -- we now follow the
   same in Python bindings to ensure charts created in one locale
   will continue to work in another.
2017-12-10 10:16:57 +00:00
Alejandro Martinez
b3680c0dd1 Enabled sequence behavior on PythonDataSeries
Adding __getitem__ makes it to behave like a sequence enabling indexing
and iteration,for example:
s = GC.series(6)
print(s[0], s[-1])
for v in s: print(s)
l = list(s)
print(l.count(0))
2017-12-09 20:36:03 -03:00
Mark Liversedge
385b56ee47 Python GC.activity()
.. very basic API as we develop out, it just returns a dict
   for now. Need to expand to enable returning a list if
   compare mode is active (like R).

.. implemented in a new source file Resources/python/library.py
   which is loaded directly after the interpreter is loaded at
   startup.

.. also updated src.pro to add library.py and goldencheetah.sip
   to OTHER_FILES so they can be edited easily in QtCreator.
2017-12-09 19:52:59 +00:00
Mark Liversedge
76eaecab5a Fixup Py_ssize_t on Windows VS build
.. Py_ssize_t is not always a long, so lets use the python
   type in our bindings to keep the buffer code simple.
2017-12-09 19:08:00 +00:00
Mark Liversedge
2a5fcfe5db Python DataSeries functions
.. start of API to work with ride data, exposing the raw
   sample data via the buffer protocol python api and SIP

.. adds utility functions that will ultimately be wrapped
   inside a python class/function:

   GC.series(n) - return series data as a python array
   GC.seriesName(n) - return string describing series data
   GC.seriesLast() - returns int for last series type
   GC.seriesPresent(n) - returns True if series in ride

.. example of using these functions in python to create a
   dict object collecting all available data:

   activity = {}
   for x in range(0, GC.seriesLast()):
      if (GC.seriesPresent(x)):
         activity[GC.seriesName(x)] = GC.series(x)
2017-12-09 16:50:29 +00:00
Mark Liversedge
3a534e1ff4 Python GC.build() and GC.version()
.. simple examples, lots of generated code changes which is
   not very helpful.

.. but the only files that were edited by hand are goldencheetah.sip
   Bindings.h and Bindings.cpp
2017-12-05 19:23:38 +00:00
Mark Liversedge
db3d119f7d Python GC.athlete()
Basic proof of concept for CPP binding using SIP but with
our own type conversion (to avoid overhead of SIP lib/deploy).
Its far from perfect but will serve as a starting point.

.. needed to fixup type conversion in goldencheetah.sip to
   convert returning QString as PyUnicode

.. needed to fixup passing context when multi-threaded

.. needed to fixup Bindings.h/cpp to offer new API
2017-12-04 15:20:43 +00:00
Mark Liversedge
6d9731e1ed Fixup SIP Makefile
.. to add API header to the dependency
2017-12-04 15:20:43 +00:00
Mark Liversedge
29558420b6 remove debug
.. sigh
2017-12-02 20:09:30 +00:00
Mark Liversedge
00144effd8 Python Module Framework
.. Using SIP thats used in PyQt et al we have a module
   called `goldencheetah' which includes bindings.

   Currently there is only a single method `getValue()'
   that returns 1. It's to get the basic plumbing in place.

   src/Python/SIP contains all the files related to the
   module. The cpp files are generated by the `sip' utility
   which will need to be available if you want to work on the
   bindings. Run make -f Makefile.hack to regenerate the cpp
   files if you edit them.

   I prefer to distribute the generated files at this point
   whilst development occurs. We may change that at a later
   date.

.. Please note that the gcconfig.pri.in file has changed as
   we now include the python include path rather than set a
   macro for the include directive (See PYTHONINCLUDES in
   gcconfig.pri.in)

.. lastly, to test this is working in a python chart console:
   > print(GC.getValue())
   1
   >
2017-12-02 16:33:54 +00:00
Mark Liversedge
14e27e9486 Python Editor Syntax Highlighter
.. basic stuff for now.
2017-11-25 08:59:56 +00:00
Mark Liversedge
ab82ea004f ESC or ^C to stop long running Python script
.. when a chart script gets caught in a runaway loop let the
   user interrupt it with the ESC or ^C key.
2017-11-24 19:32:07 +00:00
Mark Liversedge
0662a41ebb Python Script Exec
.. runs in thread to avoid blocking GUI actions but GUI
   will still wait for script to complete. ESC is trapped,
   but mechanism to stop script not implemented yet.
2017-11-23 22:51:41 +00:00
Mark Liversedge
82c06b4b29 Python Chart Console
.. issue commands and have them run in the python interpreter.
.. output and errors are captured
2017-11-22 21:13:59 +00:00
Mark Liversedge
1874ddaaeb Python Chart
.. added a python chart type, it doesn't execute code
   yet. Just a reimplementation of the RChart UX

.. next we need to trap output and run code on selection
   before proceeding to setting an API for Data and Charting
2017-11-22 18:20:00 +00:00
Mark Liversedge
0a2ac3aa6b Start Python Embedding
.. just bootstrapping, so Python is loaded and version
   number made available in the about box.

.. see gcconfig.pri.in and src.pro for settings needed

.. not considering threading etc at this point
2017-11-22 15:50:22 +00:00