Results 1 to 3 of 3

Thread: Centralised data - multiple QwtPlot

  1. #1
    Join Date
    Oct 2013
    Location
    Quebec
    Posts
    31
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Centralised data - multiple QwtPlot

    Hi,

    Just a little bit of context:
    I am using 3 distinct qwtPlot that use the same data, the data is stored in multiple QVector<QPointF> in each qwtPot, (used to reprensent realtime QwtPlotCurve for each qwtPlot)
    To get a little bit what I mean, here is a video of the software in action :
    https://www.youtube.com/watch?v=NSCTaG57ze4 (fast foward to the middle)

    Now I want to change that, since using 3 times the same data uses a lot memory and is not efficient.
    I am trying to change the code so that I have only one place where all the data is stored, and the graph feeds on this data to display new contents when it arrives (with signal/slots mechanism)

    So my center class with the data is called "DataWorkout" and contains
    - QVector<QPointF> cadenceSamples;
    this Samples get filled every second with ~ 4 new QPointF
    When I get a new QPoint, this class emit a signal to the qwtPlot class so that they replot the QwtPlotCurve.

    Here is the current code used that works
    Qt Code:
    1. connect(dataWorkout, SIGNAL(newCadenceDataAdded(QVector<QPointF>)), ui->widget_workoutPlot, SLOT(refreshCadenceCurve(QVector<QPointF>)) );
    2.  
    3. void WorkoutPlot::refreshCadenceCurve(QVector<QPointF> cadenceSample)
    4. {
    5. cadenceCurve->setSamples(cadenceSample);
    6. cadenceCurve->attach(this);
    7. }
    To copy to clipboard, switch view to plain text mode 

    My question is: is passing a QVector<QPointF> in a signal/slot going to use a lot of ressource? Will it copy the entire QVector or just pass the pointer/address? I'm not sure the way I used is good but I couldn't find a way without passing the QVector in the signal/slot, because to curve doesn't get display if I don't use .setSamples and .attach on each call.

    Thanks in advance / Merci beaucoup!

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,252
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Centralised data - multiple QwtPlot

    Derive from QwtSeriesData<QPointF> so that all instances return from the same storage. There is no need to copy anything.

    Uwe

  3. #3
    Join Date
    Oct 2013
    Location
    Quebec
    Posts
    31
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Centralised data - multiple QwtPlot

    Thanks Uwe, guess if I'm thinking to do it, Qwt has already done it

    I'm reading the example "oscilloscope" that is near to what I want. In this example there is only 1 CurveData and 1 SignalData.
    Would you recommend to create 4 distinct class for my use case, one for each Data type (ie: HeartRateData, CadenceData, PowerData, SpeedData)
    Or put it all together in one class like SignalData -- (method appendHeartRate(QPointF), appendCadence(QPointF)...)

    From what I understand CurveData is where to access the data, and SignalData is where you write/modify the data.
    I still need to figure what is the .lock about and if I really need it in my use-case, I'm not reploting manually but at fixed time interval in my case.
    Wish I had your programming skills

    [Edit : I used the same code from "oscilloscope" and it's working well
    Qt Code:
    1. cadenceCurve->setData(new CurveData() );
    2. cadenceCurve->attach(this);
    To copy to clipboard, switch view to plain text mode 
    Now just to see the code design but i'll probably code 4 classes to separate my signals data from each other
    but with this way I need 4 classes for the curveData and 4 classes for the SignalData, lot of code to maintain will see if I can make all in 2 classes.. ]

    Thank you
    Last edited by Maximus2; 25th March 2014 at 16:44.

Similar Threads

  1. Replies: 5
    Last Post: 4th March 2014, 18:01
  2. QwtPlotRenderer for multiple QwtPlot
    By Momergil in forum Qwt
    Replies: 1
    Last Post: 18th January 2013, 12:09
  3. QwtPlot - multiple axis
    By MukundanAR in forum Qwt
    Replies: 1
    Last Post: 7th March 2012, 08:53
  4. QwtPlot - multiple axis
    By MukundanAR in forum Newbie
    Replies: 0
    Last Post: 6th March 2012, 12:50
  5. Replies: 1
    Last Post: 18th July 2011, 08:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.