uwerat / qskinny

A lightweight framework on top of the Qt scene graph and only few classes from Qt/Quick. It is usable from C++ and/or QML.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QskGraphic: Scale factors are still off for painter paths

peter-ha opened this issue · comments

The following program calculates zoom factors for painter paths that are still too small for the attached shape (needs to be unpacked first).

Screenshot from 2023-01-18 12-06-55

#include <QtGui>

#include <SkinnyShortcut.h>

#include <QskGraphic.h>
#include <QskGraphicIO.h>
#include <QskGraphicLabel.h>
#include <QskSetup.h>
#include <QskWindow.h>

int main( int argc, char** argv )
{
    QGuiApplication app( argc, argv );

    SkinnyShortcut::enable( SkinnyShortcut::Quit | SkinnyShortcut::DebugShortcuts );

    QskWindow w;
    w.setPreferredSize( { 500, 500 } );

    QskGraphic  = QskGraphicIO::read( QStringLiteral( "shape.graphic" ) );

    new QskGraphicLabel( graphic, w.contentItem() );

    w.show();
    return app.exec();
}

shape.graphic.tar.gz

So the purpose of QskGraphicPrivate::PathInfo::scaleFactor*() is for the pen to not draw beneath the rect, because in our initial scale factor calculation we only take the pointRect into account, is that correct?

Unfortunately we can't simply use QPainterPath::controlPointsRect() because of the pens, that might grow out of bounds when being scaled. The code in the scaleFactor methods should be about trying to address this problem.

But this code is derived from code of the Qwt Project - something I wrote > 10 years ago - and I can't remember if tested all corner cases back in the days.