Results 1 to 3 of 3

Thread: QwtPlotItem copy, or better solution

  1. #1
    Join Date
    Jun 2014
    Posts
    8
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default QwtPlotItem copy, or better solution

    Hello all,
    my question: is it possible to copy QwtPlotItem(curve, or shape for example), for used it later after it was used once? Easier explain: I want to initialize
    Qt Code:
    1. QwtPlotShapeItem *shape1;
    2. shape1 = new QwtPlotShape;
    3. shape1.setRect(...);
    To copy to clipboard, switch view to plain text mode 
    then attach this item to plot:
    Qt Code:
    1. shape1->attach(ui->qwtPlot);
    2. ui->qwtPlot->replot();
    To copy to clipboard, switch view to plain text mode 
    . Then clear this plot, use some other items, and then again attach this shape1:
    Qt Code:
    1. ui->qwtPlot->detachItems();
    2. shape1->attach(ui->qwtPlot);
    3. ui->qwtPlot->replot;
    To copy to clipboard, switch view to plain text mode 
    But now, I think item after "attach" metod going out and losing a date. I tried to copy:
    Qt Code:
    1. QwtPlotShapeItem shape2;
    2. shape2 = shape1;
    To copy to clipboard, switch view to plain text mode 
    but it seems to copy only poiter to first data. And after applying shape2, item shape1 also clearing. Ofc I tried copy *shape2 = *shape1; But compiler says so QwtPlotShapeItem::d_data* is private.
    So Im looking a way to keep QwtPlotItem in memory for multi-using it. Way with saving date for this items and generete new items every time from date I now, but I have a lot of date and I need perfomance, so that is a question.

    Let me try describe my task in general, mb someone can suggest better solution:
    I getting a text file with date - spectrogram. Date its multiplicity of rectangles and temperatures for them. For example one file can contains 100 different plot-s with 6000 rectangles for each plot. For draw it in QwtPlot I just drawing rectangles with color witch obtained through QwtLinearColorMap from temperature value. General task is to try make animation from this plots in qwtPlot - so replot this date in QwtPlot as fast as possible (not faster then 24 fps) Ofcourse Im going to keep all this date in prog memory, but now I can work succesfull only like keep this date like multiplicity of QRectF-s and QColor-s and for every plot going to create new QwtPlotItemShape -> setRect/setBrush... Perfomance witch I got: 2-2.2 plot/second (ofc depens from computer, but it for work pc). In case if I will keep in memory ready QwtPlotItemShapes, I will have around 8-9 plot/sec...better, but I cannot use twice items wich was attached already(first question of topic.). Actually best solution can be store ready content of QwtPlot as a whole (mb plotLayout, but Idc what is it and how it work...).
    So I would be very gratefull if someone can give me some recommendation about copy of QwtItes or in gereral about solution for my task. Feel free to clarify, if my describtion is unclear.
    Last edited by Asting; 8th June 2014 at 19:22.

  2. #2
    Join Date
    Dec 2013
    Location
    Toronto, Canada
    Posts
    62
    Thanked 16 Times in 15 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtPlotItem copy, or better solution

    The copy constructor is declared private... i.e. disabled.

    ui->qwtPlot->detachItems();
    Calling detachItems() without arguments causes all QwtPlotItem::Rtti_PlotItem to be detached and deleted.

    You need to call detachItems() with arguments. In particular the second argument must be false to prevent the item from being deleted.

    If I follow you correctly, QwtPlotItem::setVisible() might be an option

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

    Asting (14th June 2014)

  4. #3
    Join Date
    Jun 2014
    Posts
    8
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QwtPlotItem copy, or better solution

    tnx for answer Cah,
    detachItems() with Rtti argumet very useful, Im going to this way.
    Also I found, that in this command can be specified argument for auto-deliting detached items, and by default it delet, but this way is not realy usefull for me.

Similar Threads

  1. Replies: 0
    Last Post: 21st April 2014, 04:36
  2. Replies: 1
    Last Post: 16th March 2011, 18:53
  3. Replies: 0
    Last Post: 18th January 2011, 02:19
  4. QwtPlotItem inverting qwtPlot scale
    By jmsbc in forum Qwt
    Replies: 1
    Last Post: 25th August 2009, 14:09
  5. Replies: 3
    Last Post: 16th May 2009, 10:16

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.