Results 1 to 20 of 20

Thread: Regarding plotting using .csv file in QWT

  1. #1
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Regarding plotting using .csv file in QWT

    Hi Uwe,

    I am using qwt library to draw a graph of Time Vs Temperature in my project
    where the data is fed to curve by reading from a csv file as a text.

    However I am able to read the values of the csv file when I qdebug in my code,
    but am not able to draw those on to the plot.

    The QwtPlotCurve class takes parameters only in double and converting the string
    info from .csv file to double and feeding it by still it is not drawing those
    values.The csv file contains Time and temperature and this data set/pair comes
    for every 5 secs.
    setRawSamples() function i am using.

    Do you have any examples which read csv file and plot accordingly?

    Does qwt supports Embedded Linux as well? also does it support touch events such
    as thumb and fore finger zooming, panning right now they are happening from
    classes QwtPlotPanner and QwtPlotMagnifier through mouse events.

    These are versions that I am using currently
    QtCreator: 2.0.1
    Qt Version : 4.7
    QWT Version: 6.0.1

    Awating your reply.

    Thanks in advance.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,053
    Thanks
    233
    Thanked 649 Times in 639 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Regarding plotting using .csv file in QWT

    Hello Ravikiran,

    Many of the people who subscribe to the Qwt mailing list also watch this forum.

    You didn't like the answer you got in the mailing list, so you thought reposting the exact same question here would get you a different answer? That is a little bit insulting to people who are polite enough to give you an answer, don't you think?

    David

  3. #3
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi David,

    Its not so.I am not insulting any one. I did not find QWT mailing list that much friendly and was also not able get clearly see responses to my questions as I have registered to it recently.
    The day I posted my question on QWT mailing list , I also posted in QtCentre as well.So no question of insulting, as I was even not knowing that many people are registered with QWT mailiing list.

    BR,
    Ravikiran

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,188
    Thanked 843 Times in 792 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Regarding plotting using .csv file in QWT

    Back to your CSV files I recommend to organize your question like you would organize your code:


    • How to load a CSV files into a QPolygonF
    • How to display a QPolygonF on a QwtPlot


    The first question is completely unrelated to Qwt and I'm pretty sure that you can solve this problem easily. If not ask in the newbie section of this forum or google for "csv file qt".

    The second question is simply:

    Qt Code:
    1. curve->setSamples( polygon );
    To copy to clipboard, switch view to plain text mode 
    Uwe

  5. The following user says thank you to Uwe for this useful post:

    Aster036 (23rd April 2012)

  6. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,053
    Thanks
    233
    Thanked 649 Times in 639 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Regarding plotting using .csv file in QWT

    Its not so.I am not insulting any one. I did not find QWT mailing list that much friendly and was also not able get clearly see responses to my questions as I have registered to it recently.
    The day I posted my question on QWT mailing list , I also posted in QtCentre as well.So no question of insulting, as I was even not knowing that many people are registered with QWT mailiing list.
    OK, my mistake for jumping to a conclusion. I apologize. In case you did not get the answer I posted to the Qwt mailing list, here it is:

    > Do you have any examples which read csv file and plot accordingly?

    Posting a question with no example code means that we have to guess what
    you might be doing wrong. We can make up answers all day long and never
    know if we've told you the real answer. It is like asking "How long is
    a piece of string?"

    Reading data points from *anywhere* and plotting them using QwtPlot are
    completely unrelated problems.

    - Have you looked at the arrays of data you are sending to QwtPlot to
    see if they actually contain the numbers you see in your CSV file? How
    do you know the reading is successful? How do you know the parsing from
    string to number is successful?

    - If the arrays *do* contain the numbers you expect, how do you allocate
    these arrays? The setRawData() method *requires* that the array
    pointers be valid for the lifetime of the QwtPlotCurve that is using
    them. If your arrays go out of scope before the curve does, then the
    curve is trying to use invalid pointers to draw.

    - Did you set the axis ranges to match the data ranges? If the data is
    outside the range of the plot, then the curve might be drawn, but
    nothing is visible because it is outside the axes.

    - Did you set the curve style to be "Lines" and the pen to be something
    visible? If the style is set to "NoCurve", then it will be invisible.

    > also does it support touch events

    David

  7. The following user says thank you to d_stranz for this useful post:

    Aster036 (23rd April 2012)

  8. #6
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi Uwe,

    Thanks for the earlier answer.

    My other concern is does Qwt support embedded Linux? because my project is very much based on Qt Embedded Linux 4.7 running on Free scale's IMX 233 H/W board with ARM 11 Compiler which also need to support plot zoom and panning.

    Is it straight forward process or do we have do put some effort?Please revert back to this.

    BR,
    Aster

  9. #7
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,188
    Thanked 843 Times in 792 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Regarding plotting using .csv file in QWT

    Quote Originally Posted by Aster036 View Post
    My other concern is does Qwt support embedded Linux?
    I never heard of a platform. where someone was running Qt and Qwt didn't work - Qwt depends on Qt and the C-library only, no other libraries ( boost, STL ) are used.

    I know many applications running QWS on embedded Linux ( see youtube ) and wrote large applications in this environment myself - but of course you always have to check your environment yourself.

    Uwe

  10. #8
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi ,

    When installing qwt-6.0.0-rc5 on Ubuntu 10.04 I am getting below error :

    1) qmake qwt.pro works fine
    2) when ran command "make" it is giving below error:

    /Desktop/qwt-6.0.0-rc5$ make
    cd src && make -f Makefile
    make[1]: Entering directory `/home/ravi/Desktop/qwt-6.0.0-rc5/src'
    compiling qwt_interval.cpp
    In file included from qwt_interval.cpp:10:
    qwt_interval.h:24: error: variable ‘QWT_EXPORT QwtInterval’ has initializer but incomplete type
    qwt_interval.h:24: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
    qwt_interval.h:26: error: expected primary-expression before ‘public’
    qwt_interval.h:26: error: expected ‘}’ before ‘public’
    qwt_interval.h:26: error: expected ‘,’ or ‘;’ before ‘public’
    qwt_interval.h:51: error: expected constructor, destructor, or type conversion before ‘;’ token
    qwt_interval.h:53: error: ‘IncludeBorders’ was not declared in this scope
    qwt_interval.h:53: error: expected constructor, destructor, or type conversion before ‘;’ token
    qwt_interval.h:56: error: ‘IncludeBorders’ was not declared in this scope
    qwt_interval.h:58: error: ‘QwtInterval’ does not name a type
    qwt_interval.h:59: error: ‘QwtInterval’ does not name a type
    qwt_interval.h:60: error: ‘QwtInterval’ does not name a type
    qwt_interval.h:62: error: ISO C++ forbids declaration of ‘QwtInterval’ with no type
    qwt_interval.h:62: error: expected ‘,’ or ‘...’ before ‘&’ token
    qwt_interval.h:62: error: non-member function ‘bool operator==(int)’ cannot have cv-qualifier
    qwt_interval.h:62: error: ‘bool operator==(int)’ must have an argument of class or enumerated type
    qwt_interval.h:63: error: ISO C++ forbids declaration of ‘QwtInterval’ with no type
    qwt_interval.h:63: error: expected ‘,’ or ‘...’ before ‘&’ token
    qwt_interval.h:63: error: non-member function ‘bool operator!=(int)’ cannot have cv-qualifier
    qwt_interval.h:63: error: ‘bool operator!=(int)’ must have an argument of class or enumerated type
    qwt_interval.h:66: error: non-member function ‘int borderFlags()’ cannot have cv-qualifier
    qwt_interval.h:68: error: non-member function ‘double minValue()’ cannot have cv-qualifier
    qwt_interval.h:69: error: non-member function ‘double maxValue()’ cannot have cv-qualifier
    qwt_interval.h:71: error: non-member function ‘double width()’ cannot have cv-qualifier
    qwt_interval.h:76: error: non-member function ‘bool contains(double)’ cannot have cv-qualifier
    qwt_interval.h:78: error: ISO C++ forbids declaration of ‘QwtInterval’ with no type
    qwt_interval.h:78: error: expected ‘,’ or ‘...’ before ‘&’ token
    qwt_interval.h:78: error: non-member function ‘bool intersects(int)’ cannot have cv-qualifier
    qwt_interval.h:79: error: ‘QwtInterval’ does not name a type
    qwt_interval.h:80: error: ‘QwtInterval’ does not name a type
    qwt_interval.h:82: error: expected constructor, destructor, or type conversion before ‘operator’
    qwt_interval.h:83: error: expected constructor, destructor, or type conversion before ‘operator’
    qwt_interval.h:85: error: expected constructor, destructor, or type conversion before ‘&’ token
    qwt_interval.h:86: error: expected constructor, destructor, or type conversion before ‘&’ token
    qwt_interval.h:88: error: ‘QwtInterval’ does not name a type
    qwt_interval.h:89: error: expected constructor, destructor, or type conversion before ‘operator’
    qwt_interval.h:90: error: expected constructor, destructor, or type conversion before ‘&’ token
    qwt_interval.h:92: error: non-member function ‘bool isValid()’ cannot have cv-qualifier
    qwt_interval.h:93: error: non-member function ‘bool isNull()’ cannot have cv-qualifier
    qwt_interval.h:96: error: ‘QwtInterval’ does not name a type
    qwt_interval.h:98: error: expected unqualified-id before ‘private’
    qwt_interval.h:102: error: expected declaration before ‘}’ token
    make[1]: *** [obj/qwt_interval.o] Error 1
    make[1]: Leaving directory `/home/ravi/Desktop/qwt-6.0.0-rc5/src'
    make: *** [sub-src] Error 2

    what could be the problem? what is the work around?

    Thanks in advance.
    Aster


    Added after 6 minutes:


    Hi Uwe,

    I did not find csv file qt reader code, i found found tar file when googled, but it was empty.

    So if you have any link or code please let me know.

    Thanks in advance.

    BR,
    Aster
    Last edited by Aster036; 24th April 2012 at 10:54.

  11. #9
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,188
    Thanked 843 Times in 792 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Regarding plotting using .csv file in QWT

    Even if I would expect that it is unrelated: nobody will answer for qwt-6.0.0-rc5, when there are official Qwt 6.0.x releases for a long time.
    Back to your problem: try "type qmake" to see if your qmake is from a Qt version that is compatible with Qwt 6.x.

    Uwe

  12. #10
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    > Do you have any examples which read csv file and plot accordingly?

    Posting a question with no example code means that we have to guess what
    you might be doing wrong. We can make up answers all day long and never
    know if we've told you the real answer. It is like asking "How long is
    a piece of string?"

    Reading data points from *anywhere* and plotting them using QwtPlot are
    completely unrelated problems.

    - Have you looked at the arrays of data you are sending to QwtPlot to
    see if they actually contain the numbers you see in your CSV file? How
    do you know the reading is successful? How do you know the parsing from
    string to number is successful?

    -- I am able to see the read csv values in the command prompt when I print them on the screen using qDebug() macro.

    - If the arrays *do* contain the numbers you expect, how do you allocate
    these arrays? The setRawData() method *requires* that the array
    pointers be valid for the lifetime of the QwtPlotCurve that is using
    them. If your arrays go out of scope before the curve does, then the
    curve is trying to use invalid pointers to draw.

    --- What class should I use I am not getting QwtSeriesData or QwtArraySeriesData?
    ---- I have not allocated anything as of now.

    - Did you set the axis ranges to match the data ranges? If the data is
    outside the range of the plot, then the curve might be drawn, but
    nothing is visible because it is outside the axes.

    --- I have set the axis ranges according to my data.
    ----

    - Did you set the curve style to be "Lines" and the pen to be something
    visible? If the style is set to "NoCurve", then it will be invisible

    ---I have not set any style to the curve.

  13. #11
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi ,

    I am trying to create graph which is attachedtemplog_spec_qwt_post.jpg.
    (templog_spec_qwt_post.png)
    But as of now the status is like the one attached myapp.png.

    Please suggest how to get the scales like the one specified(templog_spec), also I want to plot graph dynamically
    where the data is coming for every 5 seconds, the data is Time and its corresponding temperature in a csv format.

    It may not be smooth sinusoidal curve as the templog_spec is showing.

    Thanks in advance.

    Aster

  14. #12
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi

    I am now using latest build of qwt-6.0.1 on Ubuntu 10.04, but when tried to install qwt am getting below error:


    qmake is /usr/local/Trolltech/Qt-4.7.0/bin/qmake
    root@ubuntu:/home/ravi/Desktop/qwt-6.0.1# qmake qwt.pro
    root@ubuntu:/home/ravi/Desktop/qwt-6.0.1# make
    cd src/ && make -f Makefile
    make[1]: Entering directory `/home/ravi/Desktop/qwt-6.0.1/src'
    g++ -c -pipe -g -Wall -W -O2 -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I/usr/include/qt3 -Imoc/ -o obj/qwt_abstract_scale_draw.o qwt_abstract_scale_draw.cpp
    In file included from qwt_scale_div.h:14,
    from qwt_abstract_scale_draw.h:14,
    from qwt_abstract_scale_draw.cpp:10:
    qwt_interval.h:15: fatal error: qdebug.h: No such file or directory
    compilation terminated.
    make[1]: *** [obj/qwt_abstract_scale_draw.o] Error 1
    make[1]: Leaving directory `/home/ravi/Desktop/qwt-6.0.1/src'
    make: *** [sub-src-make_default-ordered] Error 2

    I think its a well known problem , I did not get any where work around for this. Please help on this.

    Thanks in advance.

    Aster.

  15. #13
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,188
    Thanked 843 Times in 792 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Regarding plotting using .csv file in QWT

    Quote Originally Posted by Aster036 View Post
    ...-I/usr/share/qt3/mkspecs/default -I. -I/usr/include/qt3 ...
    Obviously you are trying to build Qwt 6.x with Qt3.

    Uwe

  16. #14
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi Uwe,

    Can you please reply on my post which has two images attached.

    Thanks in advance.

  17. #15
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi ,

    I tried to download qt csv file from below site:

    http://qcsv.svn.sourceforge.net/

    but when unzipped the file contains nothing, if you have csv file reader in Qt app download link please share.

    Thanks and Regards

  18. #16
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,053
    Thanks
    233
    Thanked 649 Times in 639 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Regarding plotting using .csv file in QWT

    -- I am able to see the read csv values in the command prompt when I print them on the screen using qDebug() macro.
    You said this in an earlier post. If you are already able to read your data from the CSV file, then why are you wasting time downloading something from SourceForge? An if you go to the SF page you linked to , you will see that it clearly says:

    Files shown: 0
    so why are you surprised when your tarball is empty?

    Posting two images (one of which is clearly something made using a graphics editing program, not with Qwt) and asking "What am I doing wrong?" - How are we supposed to know? You have not shown us ANY SOURCE CODE AT ALL. How are we supposed to guess what you are doing wrong when you have told us absolutely nothing about what you are doing?

  19. #17
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi ,


    Please find the attached files of my application.

    Right now I am plotting the graph for 30 hard coded values , but they should be read from the csv files which are added as resources.

    Thanks in advance.
    Attached Files Attached Files

  20. #18
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi

    Does anybody has qwt example code which does dynamic plotting ? Please share the same.

    Thanks in advance.

  21. #19
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,053
    Thanks
    233
    Thanked 649 Times in 639 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Regarding plotting using .csv file in QWT

    I have looked at your code. It is clear to me from the fact that there are more lines of commented out code than there are non-commented lines that you really don't have any idea how to do what you want. I think you are totally confusing things and making it more difficult than it is. From what I understand, you want to do two things:

    1 - Read time and temperature strings from a CSV file and convert them to numbers
    2 - Create a Qwt plot that displays the temperature vs . time values as a curve

    First, you have to understand that reading the data and plotting the data are completely unrelated activities. So don't mix them all up in the same method (or even the same C++ class). Make a C++ class whose job is to read the data file and return the x and y arrays of doubles. It basically needs three methods and a couple of arrays:

    Qt Code:
    1. class CSVReader
    2. {
    3. public:
    4. CSVReader() {}
    5.  
    6. // opens the CSV file, reads the data into time and temperature arrays, returns true if OK, false otherwise
    7. bool readDataFromFile( const QString & fileName );
    8.  
    9. const QVector<double> & temperature() const { return mTemperature; }
    10. const QVector<double> & time() const { return mTime; }
    11.  
    12. private:
    13. QVector<double> mTemperature;
    14. QVector<double> mTime;
    15. };
    To copy to clipboard, switch view to plain text mode 

    Next, use this class to read the data, then pass the data to your curve:

    Qt Code:
    1. CSVReader dataSource;
    2.  
    3. if ( dataSource.readDataFromFile( "myfile.csv" ) )
    4. {
    5. const QVector<double> & temps = dataSource.temperature();
    6. const QVector<double> & times = dataSource.time();
    7. curve->setSamples( times.data(), temps.data(), times.size() ); // makes a copy of the data
    8. }
    To copy to clipboard, switch view to plain text mode 

    That's about as simple as it gets. Please notice, any two QVector<double> instances could be used to build the curve. The fact that the vectors were created by reading a CSV file is completely irrelevant as far as the plot is concerned. A tiny spaceship could land on your PC and a little green man could step out and hand you two vectors, and they would work the same way as far as the plot is concerned.

  22. #20
    Join Date
    Apr 2010
    Location
    Bangalore
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Regarding plotting using .csv file in QWT

    Hi Stranz,

    Thanks a ton for your useful post.

    I was bit stranded as to what to do and what am I doing wrong?

    I shall get back to you if I get some more new problems.

    Thank you.
    Aster

Similar Threads

  1. Plotting in 3D
    By FelixB in forum Qwt
    Replies: 1
    Last Post: 1st October 2010, 16:26
  2. Using QGLWidget for plotting
    By llemes4011 in forum Qt Programming
    Replies: 4
    Last Post: 28th July 2010, 14:40
  3. Replies: 0
    Last Post: 4th August 2009, 15:24
  4. Plotting graph of 1/x
    By Persoontje in forum Qwt
    Replies: 1
    Last Post: 20th March 2009, 14:26
  5. Plotting from Left to Right ??
    By dheeraj in forum Qwt
    Replies: 3
    Last Post: 3rd June 2008, 07:09

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.