Results 1 to 3 of 3

Thread: Syncing many QwtPlots with QwtPlotPickers

  1. #1
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Syncing many QwtPlots with QwtPlotPickers

    I have many QwtPlot objects sharing the same points data in XY coordinates. There can be like 10 curves in one plot. I want display some curves in first plot window and some other curves in second, etc.

    Each plot would have drawn their y-axis but there would be only one common x-axis. Plots are stacked vertically and I want one common vertical tracker .

    I have some ideas but would this work ?

    - each QwtPlot has QwtPlotPicker installed and can draw vertical tracker.
    - each plot has slot for 'selected' signal from the picker
    - when plot receives 'selected' from picker it sends same signal to other plots with same arguments (that contain position)

    I think this could work if the plot sizes are exactly the same. Would it be better to have plot translate mouse point to curve's point in x-axis and send that info to others?
    Last edited by phenoboy; 31st May 2016 at 08:52.

  2. #2
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Syncing many QwtPlots with QwtPlotPickers

    I am going to try to create a top level container, vertical layout that can draw vertical line. I then map mouse events to children QwtPlot widgets... from there I should be able to draw tracker with curve values.

  3. #3
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Syncing many QwtPlots with QwtPlotPickers

    srYj1Hw.jpgOk, seems almost to be working:

    srYj1Hw.jpg

    Looks like my mapping is a little bit off. Mouse is a little left from the 0 point but it reads more than zero:


    Here's the code I'm using
    Qt Code:
    1. //global vertical line on top level widget that holds individual pots, picker for global point
    2. picker = new QwtPicker(QwtPlotPicker::VLineRubberBand, QwtPicker::AlwaysOn,
    3. this);
    4. picker->setStateMachine(new QwtPickerTrackerMachine);
    5. picker->setTrackerMode(QwtPicker::AlwaysOff);
    6. picker->setRubberBand(QwtPicker::VLineRubberBand);
    7. picker->setRubberBandPen(QColor(Qt::blue));
    8.  
    9. connect(picker, SIGNAL(moved(const QPoint&)),this,SLOT(onMoved(const QPoint&)));
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MultiPlot::onMoved(const QPoint &p)
    2. {
    3. QPoint global= this->mapToGlobal(p);
    4. qDebug() << "onMoved" << p <<", global:" << global << "plot1 fromglobal: " << plot1->mapFromGlobal(global);
    5.  
    6. QPoint pos=plot1->mapFromGlobal(global);
    7.  
    8. //invTransform
    9. QwtScaleMap xMap = plot1->canvasMap( QwtPlot::xBottom );
    10. QwtScaleMap yMap = plot1->canvasMap( QwtPlot::yLeft );
    11.  
    12. QPointF posF = QPointF(
    13. xMap.invTransform( pos.x() ),
    14. yMap.invTransform( pos.y() )
    15. );
    16.  
    17. plot1Picker->onSelected(posF);
    18. qDebug() << "posF=" << posF;
    19.  
    20. global= this->mapToGlobal(p);
    21. qDebug() << "onMoved" << p <<", global:" << global << "plot2 fromglobal: " << plot2->mapFromGlobal(global);
    22.  
    23. QPoint pos2=plot2->mapFromGlobal(global);
    24.  
    25. //invTransform
    26. xMap = plot2->canvasMap( QwtPlot::xBottom );
    27. yMap = plot2->canvasMap( QwtPlot::yLeft );
    28.  
    29. QPointF pos2F = QPointF(
    30. xMap.invTransform( pos2.x() ),
    31. yMap.invTransform( pos2.y() )
    32. );
    33.  
    34. plot2Picker->onSelected(pos2F);
    35.  
    36. qDebug() << "pos2F=" << pos2F;
    37.  
    38. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. align stacked QwtPlots
    By mastupristi in forum Qwt
    Replies: 1
    Last Post: 30th April 2016, 10:38
  2. Syncing Android Calendar with our own calendar?
    By Awareness in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 16th February 2014, 20:17
  3. Syncing database between mobile device and PC
    By tyrnikeisari in forum Qt Programming
    Replies: 2
    Last Post: 14th June 2011, 17:21
  4. Axis problem with tiling QWTplots
    By dtakeshita in forum Qwt
    Replies: 7
    Last Post: 6th December 2010, 12:00
  5. Multiple QwtPlots in one frame?
    By rambo83 in forum Qwt
    Replies: 0
    Last Post: 7th January 2010, 09:03

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.