Results 1 to 3 of 3

Thread: Plot data stored in a hashmap

  1. #1
    Join Date
    Apr 2011
    Location
    Bayreuth, Bayern
    Posts
    24
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Plot data stored in a hashmap

    Hey!
    I want to draw a 2D-histogram, i.e. a scatter plot with different intensity values for every point. I am not quite sure whether I understand the hierarchy of Qwt correctly, and because there is a lot of inheritance in my case, I decided to seek your advice.

    I store the data which has to be drawn in a hash table, keys are (x,y)-pairs, values are the intensities which shall be displayed in different colors on the plot. I want to efficiently access the Google’s DenseHashMap & avoid conversion from a hash map into a vector. So, my problem is to plot data stored in a hash map.

    I thought I’d inherit QwtSeriesData<QwtPoint3D> template class & implement QwtPoint3D sample(size_t i) const member function (SeriesData : QwtSeriesData<QwtPoint3D>), my hash table is contained inside this class. I create a plot item Series : public QwtPlotSeriesItem<QwtPoint3D> & implement draw() & drawSeries() methods. Series shall contain data in a SeriesData container. In the draw method, I shall change the pen color depending on the intensity of the QwtPoint3D.

    Does this sound plausible to you? Do you see a better way to do this? I am really not sure in the hierarchy of Qwt & I want to be on the safe side before I run into dead-end and spend days trying to refactor the B.

    Thanks in advance!

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

    Default Re: Plot data stored in a hashmap

    I thought I’d inherit QwtSeriesData<QwtPoint3D> template class & implement QwtPoint3D sample(size_t i) const member function (SeriesData : QwtSeriesData<QwtPoint3D>), my hash table is contained inside this class.
    Yep, all you need to take care of is that you have a fast implementation of sample(). It might help to use the fact, that it is usually called one by one in increasing order.

    I create a plot item Series : public QwtPlotSeriesItem<QwtPoint3D> & implement draw() & drawSeries() methods. Series shall contain data in a SeriesData container. In the draw method, I shall change the pen color depending on the intensity of the QwtPoint3D.
    This is exactly what QwtPlotSpectroCurve does.

    Uwe

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

    missoni (5th March 2013)

  4. #3
    Join Date
    Apr 2011
    Location
    Bayreuth, Bayern
    Posts
    24
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Plot data stored in a hashmap

    Thanks Uwe, for the invaluable insight! My primary implementation of sample() iterated to the item i from the beginning of the hash table. That implementation took 2 minutes to load the whole series! With a floating iterator which stores its previous position and for each new call of sample() moves one step to front, 200 000 series points are loaded in only a few hundredth of a second!

    Thanks!

Similar Threads

  1. Replies: 9
    Last Post: 23rd December 2011, 15:56
  2. How to view data stored in Qmap or QList
    By sankar in forum Newbie
    Replies: 6
    Last Post: 17th February 2011, 09:30
  3. Replies: 4
    Last Post: 28th August 2010, 13:17
  4. [java] extract the value from a HashMap
    By mickey in forum General Programming
    Replies: 2
    Last Post: 16th August 2009, 18:16
  5. QObjects as data members stored by value
    By Radagast in forum Qt Programming
    Replies: 3
    Last Post: 6th August 2009, 19:14

Tags for this Thread

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.