About algorithm render tachometer gauge on embedded catalog example and demo



  • I read source code in file qtsvgdialgauge.cpp and qtsvgdialgauge.h and in method QtSvgDialGauge::paintEvent I don't understand code lines:
    @void QtSvgDialGauge::setNeedleOrigin(qreal x, qreal y)
    {
    m_originX = qMin(static_cast<qreal>(1.0), qMax(static_cast<qreal>(0.0), x));
    m_originY = qMin(static_cast<qreal>(1.0), qMax(static_cast<qreal>(0.0), y));
    }@
    what is needle origin ,....
    @// Tachometer
    QtSvgDialGauge *gauge = new QtSvgDialGauge(group);
    gauge->setSkin("Tachometer");
    gauge->setNeedleOrigin(0.486, 0.466);@
    why is 0.486 and 0.466
    please help me understand this. Thank in advance!

    [edit : Please use code tags (@ before and after your code) , Eddy]



  • @
    void QtSvgDialGauge::setNeedleOrigin(qreal x, qreal y)
    {
    // make sure x is between 0 and 1
    m_originX = qMin( // originX = the smaller value of
    static_cast<qreal>(1.0), // 1 and
    qMax( // the bigger value of
    static_cast<qreal>(0.0), // 0 and
    x)); // x

    // make sure y is between 0 and 1
    m_originY = qMin(static_cast<qreal>(1.0), qMax(static_cast<qreal>(0.0), y));
    

    }@

    [quote]
    @// Tachometer
    QtSvgDialGauge *gauge = new QtSvgDialGauge(group);
    gauge->setSkin("Tachometer");
    gauge->setNeedleOrigin(0.486, 0.466);
    @

    why is 0.486 and 0.466
    [/quote]
    It probably looks best...



  • I still don't understand why make sure y is between 0 and 1?
    I think 0.486 and 0.466 not "it probably looks best..."
    anyone can explain for me?



  • [quote author="banlinhtienphong" date="1316958365"]I still don't understand why make sure y is between 0 and 1?[/quote] I assume the coordinates need to be defined within the square (0.0,0.0)-(1.0,1.0). If that's the case, they're making sure the needle origin is within sight.

    [quote author="banlinhtienphong" date="1316958365"]
    I think 0.486 and 0.466 not "it probably looks best..."
    anyone can explain for me?[/quote]What don't you understand? Do you not understand why the needle origin is just a tad off-center (so not (0.5, 0.5))? Do you not understand what the needle origin is to begin with?

    It seems you're a non-native English speaker, and I understand that can make it harder to write, but please try to state what exactly you're having trouble with.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.