Is it possible to offset/manipulate the label of the ruler when you are dragging it? Say the ruler is for limiting something from a point that is not x=0, and I would like a label that reflects the offset.
It sounds like you want to be able to track relative positions. I do not know why... but, with a little work, it can be done.
In the picker.h, augment the class by adding a variable _xReference and the accessor functions. Be sure to initialize _xReference in the picker constructor.
{
Q_OBJECT
public:
....
void setReferenePosition(double pos);
double referenePosition()const;
protected:
....
double _xReference;
};
...
inline void setReferenePosition(double pos)
{
_xReference = pos;
}
inline double referenePosition()const {return _xReference ;}
...
class Picker: public QwtPlotPicker
{
Q_OBJECT
public:
....
void setReferenePosition(double pos);
double referenePosition()const;
protected:
....
double _xReference;
};
...
inline void setReferenePosition(double pos)
{
_xReference = pos;
}
inline double referenePosition()const {return _xReference ;}
...
To copy to clipboard, switch view to plain text mode
In picker.cpp, make a change to trackerTextF()
replace... return xTitle.text() + "=" + QString::number(_rulerPos);
with... return xTitle.text() + "=" + QString::number(_rulerPos - _xReference);
and
replace... return QString::number(_rulerPos);
with... return QString::number(_rulerPos- _xReference);
Client side
...
Ruler* rv1 = new RulerV(_plot, "Vertical_1");
rv1->picker()->setReferenePosition(2);
...
Dragging rv1 to a absolute position 5.0 displays a tracking text (relative) of 3.0
Let me know how this went.
Bookmarks