How to combine two QwtScaleMap?

39 views Asked by At

I'm searching for a method to combine two QwtScaleMap.

I have:

#include <QCoreApplication>
#include <QProcess>
#include "qwt_scale_map.h"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    QwtScaleMap *scaleMapFirst = new QwtScaleMap;
    scaleMapFirst->setScaleInterval(0, 1);
    scaleMapFirst->setPaintInterval(49, 0);
    QwtScaleMap *scaleMapSecond = new QwtScaleMap;
    scaleMapSecond->setScaleInterval(-3, 3);
    scaleMapSecond->setPaintInterval(0, 1);
    qDebug() << scaleMapFirst->transform(scaleMapSecond->transform(1.194));
    return a.exec();
}

I would like to combine the two QwtScaleMap to only run the transform method once.

I found nothing on the internet.

1

There are 1 answers

0
Juze On
scaleMapFirst->setScaleInterval(
   scaleMapSecond->invTransform(scaleMapFirst->s1()),
   scaleMapSecond->invTransform(scaleMapFirst->s2())
);

With the above code line, scaleMapFirst->transform(values) works without any other scaleMap.