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
//global vertical line on top level widget that holds individual pots, picker for global point
this);
picker->setStateMachine(new QwtPickerTrackerMachine);
picker
->setTrackerMode
(QwtPicker::AlwaysOff);
picker
->setRubberBand
(QwtPicker::VLineRubberBand);
picker
->setRubberBandPen
(QColor(Qt
::blue));
connect(picker, SIGNAL(moved(const QPoint&)),this,SLOT(onMoved(const QPoint&)));
//global vertical line on top level widget that holds individual pots, picker for global point
picker = new QwtPicker(QwtPlotPicker::VLineRubberBand, QwtPicker::AlwaysOn,
this);
picker->setStateMachine(new QwtPickerTrackerMachine);
picker->setTrackerMode(QwtPicker::AlwaysOff);
picker->setRubberBand(QwtPicker::VLineRubberBand);
picker->setRubberBandPen(QColor(Qt::blue));
connect(picker, SIGNAL(moved(const QPoint&)),this,SLOT(onMoved(const QPoint&)));
To copy to clipboard, switch view to plain text mode
void MultiPlot
::onMoved(const QPoint &p
) {
QPoint global
= this
->mapToGlobal
(p
);
qDebug() << "onMoved" << p <<", global:" << global << "plot1 fromglobal: " << plot1->mapFromGlobal(global);
QPoint pos
=plot1
->mapFromGlobal
(global
);
//invTransform
xMap.invTransform( pos.x() ),
yMap.invTransform( pos.y() )
);
plot1Picker->onSelected(posF);
qDebug() << "posF=" << posF;
global= this->mapToGlobal(p);
qDebug() << "onMoved" << p <<", global:" << global << "plot2 fromglobal: " << plot2->mapFromGlobal(global);
QPoint pos2
=plot2
->mapFromGlobal
(global
);
//invTransform
xMap
= plot2
->canvasMap
( QwtPlot::xBottom );
yMap
= plot2
->canvasMap
( QwtPlot::yLeft );
xMap.invTransform( pos2.x() ),
yMap.invTransform( pos2.y() )
);
plot2Picker->onSelected(pos2F);
qDebug() << "pos2F=" << pos2F;
}
void MultiPlot::onMoved(const QPoint &p)
{
QPoint global= this->mapToGlobal(p);
qDebug() << "onMoved" << p <<", global:" << global << "plot1 fromglobal: " << plot1->mapFromGlobal(global);
QPoint pos=plot1->mapFromGlobal(global);
//invTransform
QwtScaleMap xMap = plot1->canvasMap( QwtPlot::xBottom );
QwtScaleMap yMap = plot1->canvasMap( QwtPlot::yLeft );
QPointF posF = QPointF(
xMap.invTransform( pos.x() ),
yMap.invTransform( pos.y() )
);
plot1Picker->onSelected(posF);
qDebug() << "posF=" << posF;
global= this->mapToGlobal(p);
qDebug() << "onMoved" << p <<", global:" << global << "plot2 fromglobal: " << plot2->mapFromGlobal(global);
QPoint pos2=plot2->mapFromGlobal(global);
//invTransform
xMap = plot2->canvasMap( QwtPlot::xBottom );
yMap = plot2->canvasMap( QwtPlot::yLeft );
QPointF pos2F = QPointF(
xMap.invTransform( pos2.x() ),
yMap.invTransform( pos2.y() )
);
plot2Picker->onSelected(pos2F);
qDebug() << "pos2F=" << pos2F;
}
To copy to clipboard, switch view to plain text mode
Bookmarks