PDA

View Full Version : Different Colored Rectangles in QwtPlotPicker



cprokopiak
9th August 2010, 19:21
Hi everyone,

I would like to have one QwtPlotPicker object attached to my plot that allows me to select a rectangle of color A (for instance, green) using the left mouse button, while also being able to select a rectangle of color B (red) using the right mouse button.

Currently, I am attaching the mouse buttons to patterns like this:



signalPicker-> new MySignalPicker( canvas() );
signalPicker->setSelectionFlags( QwtPicker::RectSelection | QwtPicker::DragSelection );
signalPicker->setRubberBand( QwtPicker::RectRubberBand );
signalPicker->setMousePattern( QwtEventPattern::MouseSelect1, Qt::LeftButton );
signalPicker->setMousePattern( QwtEventPattern::MouseSelect2, Qt::RightButton );


Also, in my inherited class, MySignalPicker, I have reimplemented the widgetMousePressEvent() function:



virtual void widgetMousePressEvent( QMouseEvent* me )
{
if( mouseMatch( MouseSelect1, me ) )
{
setRubberBandPen( QColor( Qt::green ) );
}
else if( mouseMatch( MouseSelect2, me ) )
{
setRubberBandPen( QColor( Qt::red ) );
}
transition( ( QEvent* )me );
}


Hoever, it seems like only MouseSelect1 is able to draw rectangles. I've been trying to look through the source code, but I haven't had any luck yet finding out where/why only MouseSelect1 can draw rectangles.

Any help would be appreciated.

Thanks in advance,
Chris

Uwe
9th August 2010, 19:44
Use 2 pickers with different pens.

Uwe