openhumanoids / signal-scope

A live plotting tool for LCM message fields.
BSD 3-Clause "New" or "Revised" License
13 stars 18 forks source link

set configuration from the python files #29

Open jbcolme opened 8 years ago

jbcolme commented 8 years ago

From the examples, setting yLimits work but setting the timeWindow gives an error:

Traceback (most recent call last):
  File "<string>", line 7, in <module>
  File "/home/jcolmenares/development/signal-testing/oscilloscope.py", line 8, in <module>
    addPlot(timeWindow=20, yLimits=[-50, 50])
  File "<string>", line 153, in addPlot
AttributeError: PlotWidget has no attribute named 'setTimeWindow'

I'm just adding this line to the python file:

addPlot(timeWindow=20, yLimits=[-50, 50])

We would also like to be able to set the point size and line style from the python file, so that you don't have to load two files every time. Since this two things are global to all plots the idea is that the user sets them on the first plot and get done with it. If you guide me through the code a little bit I'll be more than happy to do it.

patmarion commented 8 years ago

Are you sure you have an up-to-date build on the master branch? Signal-scope includes some example scripts, and a few of them use the timeWindow attribute with error, it works. For example, this example command should work:

$ signal-scope examples/example5.py

The Python api can call any Qt function which is marked as a slot. Simply edit plotwidget.h and move the methods such as setBackgroundColor() and setPointSize() to be listed under the "public slots:" tag, then recompile. Then you can call plot.setPointSize(4) from the Python console or script.

If you submit a pull request with that change I'd be happy to accept it, please also add a demonstration to one of the example py files. Thanks!

jbcolme commented 8 years ago

Done!

The error was on my side.

About loading the configuration from python, this is what I did. Since the curve style and point size are the same for all plots, I made a function on signalScopeSetup.py called "formatOptions". I also added the time window, so if its the same for all plots you have to write it only once. Plus, added the example about how to use it to the util_example that has three plots. I'll make the pull request so you can go through the code and let me know what you think.