Results 1 to 11 of 11

Thread: Custom plot selection

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    7
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Custom plot selection

    Quote Originally Posted by Uwe View Post
    Of course it is ( see QwtPickerRubberband::drawOverlay in qwt_picker.cpp ) - or where else do you believe gets your VLineRubberBand painted ?

    Uwe
    Sorry. It's my error.

    class ChartZoomer : public QwtPlotZoomer
    // not correct
    // void drawRubberBand(QPainter *painter); // <-- it is my error!!!!
    // correct
    void drawRubberBand(QPainter *painter) const;
    }

    void drawRubberBand(QPainter *painter) const; <> void drawRubberBand(QPainter *painter);
    Last edited by gorec323; 1st March 2014 at 14:19.

  2. #2
    Join Date
    Dec 2011
    Posts
    60
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    12
    Thanked 2 Times in 2 Posts

    Default Re: Custom plot selection

    I have a similar question to the OP, so I'll put it here rather than starting a new thread, just to keep it all in context.

    How does one temporarily fill the rectangular rubberband area with a translucent color? (I want the fill visible only while the rubber band is being drawn.)

    My attempt was to override QwtPicker and re-implement drawRubberBand(), however this code actually does nothing. And even commenting-out the parent call at the end still results in the rectangular zoom outline being drawn. So I'm confused. Any advice Uwe would be appreciated.

    SETUP
    Qt Code:
    1. m_picker = new XQwtPicker( QwtPicker::RectRubberBand,
    2. QwtPicker::AlwaysOn,
    3. this->canvas() );
    4. m_picker->setRubberBandPen( QColor( Qt::green ) );
    5. m_picker->setRubberBand( QwtPicker::CrossRubberBand );
    6. m_picker->setTrackerPen( QColor( Qt::white ) );
    To copy to clipboard, switch view to plain text mode 

    SUBCLASS
    Qt Code:
    1. void XQwtPicker::drawRubberBand( QPainter *painter ) const
    2. {
    3. const QPolygon pa = QwtPicker::selection();
    4. const QRect rect = QRect( pa.first(), pa.last() ).normalized();
    5.  
    6. QColor fillColor = QwtPicker::rubberBandPen().color();
    7. fillColor.setAlpha(125);
    8.  
    9. QBrush fillBrush(fillColor);
    10.  
    11. QwtPainter::fillRect( painter, rect, fillBrush );
    12.  
    13. // QwtPicker::drawRubberBand(painter);
    14. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,326
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 880 Times in 828 Posts

    Default Re: Custom plot selection

    You also need to implement:

    Qt Code:
    1. QRegion XQwtPicker::rubberBandMask() const override;
    To copy to clipboard, switch view to plain text mode 
    The smaller the region the better - but beside of environments like remote X11 you probably won't notice much difference when returning the complete canvas rectangle.
    In your case the optimal solution would be the rectangle spanned by the w points. See https://qwt.sourceforge.io/class_qwt...04f237062b75fc

    Have a look at the implementation of QwtPicker::rubberBandMask - it will help with how to find the rectangle.

    HTH,
    Uwe

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

    alketi (11th May 2020)

Similar Threads

  1. Replies: 1
    Last Post: 24th May 2012, 12:52
  2. [Qwt] selection of curve/plot/...
    By packman2012 in forum Qt-based Software
    Replies: 0
    Last Post: 5th April 2012, 10:39
  3. Replies: 2
    Last Post: 19th April 2010, 13:49
  4. Replies: 5
    Last Post: 10th February 2010, 12:08
  5. Custom items selection in qgraphicsscene
    By yonnak in forum Qt Programming
    Replies: 7
    Last Post: 28th March 2009, 12:32

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
  •  
Qt is a trademark of The Qt Company.