{
// prepare
//setRenderHints( QPainter::Antialiasing );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
scene->setSceneRect( 0.0, 0.0, 100.0, 100.0 );
// initial transformation
QTransform transform;
setSceneRect( sceneRect );
setTransform( transform );
// x-grid
scene->addLine( 100.0, 0.0, 0.0, 0.0 );
scene->addLine( 100.0, 20.0, 0.0, 20.0 );
scene->addLine( 100.0, 40.0, 0.0, 40.0 );
scene->addLine( 100.0, 60.0, 0.0, 60.0 );
scene->addLine( 100.0, 80.0, 0.0, 80.0 );
scene->addLine( 100.0, 100.0, 0.0, 100.0 );
// y-grid
scene->addLine( 0.0, 0.0, 0.0, 100.0 );
scene->addLine( 20.0, 0.0, 20.0, 100.0 );
scene->addLine( 40.0, 0.0, 40.0, 100.0 );
scene->addLine( 60.0, 0.0, 60.0, 100.0 );
scene->addLine( 80.0, 0.0, 80.0, 100.0 );
scene->addLine( 100.0, 0.0, 100.0, 100.0 );
// QPLotScale transform check
setScene( scene );
}
{
fitInView( scene->sceneRect(), Qt::IgnoreAspectRatio );
qDebug() << transform().m11() << transform().m12() << transform().m13() << endl
<< transform().m21() << transform().m22() << transform().m23() << endl
<< transform().m31() << transform().m32() << transform().m33() << endl;
}
QPlot::QPlot( QWidget *parent )
: QGraphicsView( parent ),
scene( new QGraphicsScene() )
{
// prepare
//setRenderHints( QPainter::Antialiasing );
setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
scene->setSceneRect( 0.0, 0.0, 100.0, 100.0 );
// initial transformation
QTransform transform;
QRectF worldRect( QPointF(0.,0.), QPointF(100.,100.) );
QRectF sceneRect( QPointF(0.,0.), QPointF(100., 100.) );
QTransform::quadToQuad(QPolygon(worldRect), QPolygon(sceneRect), transform);
setSceneRect( sceneRect );
setTransform( transform );
// x-grid
scene->addLine( 100.0, 0.0, 0.0, 0.0 );
scene->addLine( 100.0, 20.0, 0.0, 20.0 );
scene->addLine( 100.0, 40.0, 0.0, 40.0 );
scene->addLine( 100.0, 60.0, 0.0, 60.0 );
scene->addLine( 100.0, 80.0, 0.0, 80.0 );
scene->addLine( 100.0, 100.0, 0.0, 100.0 );
// y-grid
scene->addLine( 0.0, 0.0, 0.0, 100.0 );
scene->addLine( 20.0, 0.0, 20.0, 100.0 );
scene->addLine( 40.0, 0.0, 40.0, 100.0 );
scene->addLine( 60.0, 0.0, 60.0, 100.0 );
scene->addLine( 80.0, 0.0, 80.0, 100.0 );
scene->addLine( 100.0, 0.0, 100.0, 100.0 );
// QPLotScale transform check
setScene( scene );
}
void QPlot::resizeEvent( QResizeEvent *event )
{
fitInView( scene->sceneRect(), Qt::IgnoreAspectRatio );
qDebug() << transform().m11() << transform().m12() << transform().m13() << endl
<< transform().m21() << transform().m22() << transform().m23() << endl
<< transform().m31() << transform().m32() << transform().m33() << endl;
}
To copy to clipboard, switch view to plain text mode
All I get is a FULL grid that stretches to fit the window size. This is okay, but...
Bookmarks