void testPieDiagram() { QgsDiagramSettings ds; QColor col1 = Qt::red; QColor col2 = Qt::yellow; col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList<QColor>() << col1 << col2; ds.categoryAttributes = QList<QString>() << "\"Pilots\"" << "\"Cabin Crew\""; ds.maxScaleDenominator = -1; ds.minScaleDenominator = -1; ds.minimumSize = 0; ds.penColor = Qt::green; ds.penWidth = .5; ds.scaleByArea = true; ds.sizeType = QgsDiagramSettings::MM; ds.size = QSizeF( 15, 15 ); ds.angleOffset = 0; QgsLinearlyInterpolatedDiagramRenderer *dr = new QgsLinearlyInterpolatedDiagramRenderer(); dr->setLowerValue( 0.0 ); dr->setLowerSize( QSizeF( 0.0, 0.0 ) ); dr->setUpperValue( 10 ); dr->setUpperSize( QSizeF( 100, 100 ) ); dr->setClassificationAttribute( 5 ); // Staff dr->setDiagram( mPieDiagram ); dr->setDiagramSettings( ds ); mPointsLayer->setDiagramRenderer( dr ); QgsDiagramLayerSettings dls = QgsDiagramLayerSettings(); dls.placement = QgsDiagramLayerSettings::OverPoint; QgsProject::instance()->writeEntry( "PAL", "/ShowingAllLabels", true ); mPointsLayer->setDiagramLayerSettings( dls ); mComposerMap->setNewExtent( QgsRectangle( -122, -79, -70, 47 ) ); QgsCompositionChecker checker( "piediagram", mComposition ); QVERIFY( checker.testComposition( mReport ) ); mPointsLayer->setDiagramRenderer( 0 ); }
void testPieDiagramExpression() { QgsDiagramSettings ds; QColor col1 = Qt::red; QColor col2 = Qt::yellow; col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList<QColor>() << col1 << col2; ds.categoryAttributes = QList<QString>() << "ln(Pilots + 1)" << "ln(\"Cabin Crew\" + 1)"; ds.maxScaleDenominator = -1; ds.minScaleDenominator = -1; ds.minimumSize = 0; ds.penColor = Qt::green; ds.penWidth = .5; ds.scaleByArea = true; ds.sizeType = QgsUnitTypes::RenderMillimeters; ds.size = QSizeF( 5, 5 ); ds.angleOffset = 0; QgsLinearlyInterpolatedDiagramRenderer *dr = new QgsLinearlyInterpolatedDiagramRenderer(); dr->setLowerValue( 0.0 ); dr->setLowerSize( QSizeF( 0.0, 0.0 ) ); dr->setUpperValue( 10 ); dr->setUpperSize( QSizeF( 40, 40 ) ); dr->setClassificationAttributeIsExpression( true ); dr->setClassificationAttributeExpression( "ln(Staff + 1)" ); dr->setDiagram( new QgsPieDiagram() ); dr->setDiagramSettings( ds ); QgsDiagramLayerSettings dls = QgsDiagramLayerSettings(); dls.setPlacement( QgsDiagramLayerSettings::OverPoint ); dls.setShowAllDiagrams( true ); // dls.setRenderer( dr ); mPointsLayer->setDiagramRenderer( dr ); mPointsLayer->setDiagramLayerSettings( dls ); QVERIFY( imageCheck( "piediagram_expression" ) ); mPointsLayer->setDiagramRenderer( 0 ); }
void testPieDiagram() { QgsDiagramSettings ds; QColor col1 = Qt::red; QColor col2 = Qt::yellow; col1.setAlphaF( 0.5 ); col2.setAlphaF( 0.5 ); ds.categoryColors = QList<QColor>() << col1 << col2; ds.categoryAttributes = QList<QString>() << "\"Pilots\"" << "\"Cabin Crew\""; ds.maxScaleDenominator = -1; ds.minScaleDenominator = -1; ds.minimumSize = 0; ds.penColor = Qt::green; ds.penWidth = .5; ds.scaleByArea = true; ds.sizeType = QgsDiagramSettings::MM; ds.size = QSizeF( 5, 5 ); ds.angleOffset = 0; QgsLinearlyInterpolatedDiagramRenderer *dr = new QgsLinearlyInterpolatedDiagramRenderer(); dr->setLowerValue( 0.0 ); dr->setLowerSize( QSizeF( 0.0, 0.0 ) ); dr->setUpperValue( 10 ); dr->setUpperSize( QSizeF( 40, 40 ) ); dr->setClassificationAttribute( 5 ); // Staff dr->setDiagram( new QgsPieDiagram() ); dr->setDiagramSettings( ds ); mPointsLayer->setDiagramRenderer( dr ); QgsDiagramLayerSettings dls = QgsDiagramLayerSettings(); dls.placement = QgsDiagramLayerSettings::OverPoint; dls.showAll = true; mPointsLayer->setDiagramLayerSettings( dls ); QVERIFY( imageCheck( "piediagram" ) ); }