Results 1 to 5 of 5

Thread: how to speed up the replot?

  1. #1
    Join Date
    Nov 2009
    Posts
    94
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question how to speed up the replot?

    Hello,

    could you tell me please, how to make the replot action faster? At the moment, I delete all QwtPlotMarkers after the their coordinates were changed and create the new ones with new coordinates and replot them then (see code below). Would it be faster if I dont delete them, but only set the new x- and yValues and then replot? Or does the function "replot()" itself cause the slow draw behavior?

    Thank you

    best regards,

    Vitali

    Qt Code:
    1. //#############################################################
    2. // this functions is responsible for creating circles( points) and setting their position on the plot
    3. void mainFrame::drawIndividuals(PopulationT<double> *population){
    4.  
    5. // first delete all circles....
    6. QList<QwtPlotItem*> topLevels;
    7. foreach (QwtPlotItem *item, d_plot->itemList()) {
    8. if (item->rtti() == QwtPlotItem::Rtti_PlotMarker)
    9. topLevels << item;
    10. }
    11. qDeleteAll(topLevels);
    12.  
    13. //... then draw them all
    14. for (unsigned i = 0; i < population->size(); ++i){
    15.  
    16. double xCoord = (*population)[ i ][ 0 ][0]; // read out the values of individuals in population
    17. double yCoord = (*population)[ i ][ 1 ][0];
    18. // create PlotMarkers to visualize the individuals
    19. QwtSymbol *symb = new QwtSymbol();
    20. symb->setBrush(QBrush(Qt::red, Qt::SolidPattern)); // red, solid color
    21. symb->setStyle(QwtSymbol::Ellipse); // it will be a circle
    22. symb->setSize(5,5);
    23. mark->setSymbol(*symb);
    24. mark->setXValue(xCoord); // set the position of marker on the plot
    25. mark->setYValue(yCoord);
    26. char idx[5];
    27. sprintf(idx,"%d", i);
    28. mark->setTitle(idx); // set title to the marker, which afterwards helps to indicate the certain individual
    29. //mark->setLabel(QwtText(idx));
    30. mark->attach(d_plot);
    31.  
    32.  
    33. }
    34. d_plot->selected_Points.clear();
    35. d_plot->selected_to_recombine.clear();
    36. d_plot->replot();
    37. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: how to speed up the replot?

    If number of markers didn't change of course it's a better idea just to change their coords and then do replot. But in any way replot() is the most time consuming part.

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

    rambo83 (11th December 2009)

  4. #3
    Join Date
    Nov 2009
    Posts
    94
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to speed up the replot?

    Hello,

    now I changed my code so that the Markers are not deleted every time, when their coords are changed, and recreated again, but just change the plot positions and then replot. Unfortunately it did not speed up the plot process. It still needs 4 seconds to replot 20 QwtPlotMarkers and a spectrogramm (which has no changes). I guess I do something wrong, because I cannot imagine that plotting 20 markers can last so long time!
    Do you have other ideas or hints, how to make it faster?

    Thank you

    best regards,

    Vitali

    Qt Code:
    1. // this functions is responsible for creating circles( points) and setting their position on the plot
    2. void mainFrame::drawIndividuals(PopulationT<double> *population){
    3.  
    4. // first delete redundant markers if the size of marker's list is bigger than the population size
    5. while(list_of_markers.size() > population->size()){
    6. list_of_markers[list_of_markers.size()-1]->detach();
    7. list_of_markers.pop_back();
    8. count_of_drawn--;
    9. }
    10.  
    11. for (int i = 0; i < population->size(); ++i){
    12.  
    13. double xCoord = (*population)[ i ][ 0 ][0]; // read out the values of individuals in population
    14. double yCoord = (*population)[ i ][ 1 ][0];
    15.  
    16. if(i > (count_of_drawn - 1)){ // if the size of plotted markers is less than the size of population, then create and plot further markers
    17.  
    18. // create PlotMarkers to visualize the individuals
    19. QwtSymbol *symb = new QwtSymbol();
    20. symb->setBrush(QBrush(Qt::red, Qt::SolidPattern)); // red, solid color
    21. symb->setStyle(QwtSymbol::Ellipse); // it will be a circle
    22. symb->setSize(5,5);
    23. mark->setSymbol(*symb);
    24. mark->setXValue(xCoord); // set the position of marker on the plot
    25. mark->setYValue(yCoord);
    26. char idx[5];
    27. sprintf(idx,"%d", i);
    28. mark->setTitle(idx); // set title to the marker, which afterwards helps to indicate the certain individual
    29. //mark->setLabel(QwtText(idx));
    30. mark->attach(d_plot);
    31.  
    32. // insert the new created marker into the marker list
    33. list_of_markers.push_back(mark);
    34.  
    35. count_of_drawn++;
    36. }
    37. else{
    38. list_of_markers[i]->setXValue(xCoord);
    39. list_of_markers[i]->setYValue(yCoord);
    40. }
    41.  
    42. }
    43. d_plot->selected_Points.clear();
    44. d_plot->selected_to_recombine.clear();
    45. d_plot->replot();
    46. }
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: how to speed up the replot?

    Please describe your plot composition and all elements that you have on this plot.

    If plot have big amount of elements or spectrogram on it (redrawing spectrogram takes large amount of calculations and time even if value() impl. is quick then size of spectrogram is big) replot should take much time.

    For spectrogram i suggest set repaint parameter to resizeOnly. As for markers and plot I suggest to draw markers on overlay widget. In this case you don't have to replot after changing their position, just redraw an overlay widget.

  6. #5
    Join Date
    Nov 2009
    Posts
    94
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to speed up the replot?

    Finally I have found out what was the reason for very slow plot behavior: I have set the flag
    Qt Code:
    1. this->setAutoReplot(true);
    To copy to clipboard, switch view to plain text mode 
    for the QwtPlot and this was obviosly the reason for the slow replot, because after I deleted this line, the replot last far less than 1 second (in contrast to 4 seconds before). It is very fast now. Also the dragging of markers is now very fast and they are reploted all together at once, so that one cannot see the FOR loop, as it could be seen before.

    best regards,

    Vitali

Similar Threads

  1. how to accelerate the replot?
    By rambo83 in forum Qwt
    Replies: 6
    Last Post: 17th March 2010, 11:11
  2. Replies: 5
    Last Post: 21st March 2009, 09:10
  3. Replot large wav file data
    By Sachtech in forum Qwt
    Replies: 1
    Last Post: 6th January 2009, 09:12
  4. Replies: 6
    Last Post: 22nd September 2008, 11:53
  5. Speed up Producer Consumer Threads
    By ^NyAw^ in forum Qt Programming
    Replies: 7
    Last Post: 29th February 2008, 18:38

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.