mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[FEATURE][composer] Data defined page size, orientation and number of pages for compositions. Funded by Canton of Neuchâtel, Switzerland
This commit is contained in:
parent
a914d433b9
commit
1e4ad28858
@ -34,6 +34,12 @@ class QgsComposition : QGraphicsScene
|
||||
ZValueAbove
|
||||
};
|
||||
|
||||
enum PaperOrientation
|
||||
{
|
||||
Portrait,
|
||||
Landscape
|
||||
};
|
||||
|
||||
//! @deprecated since 2.4 - use the constructor with QgsMapSettings
|
||||
QgsComposition( QgsMapRenderer* mapRenderer ) /Deprecated/;
|
||||
explicit QgsComposition( const QgsMapSettings& mapSettings );
|
||||
@ -403,8 +409,13 @@ class QgsComposition : QGraphicsScene
|
||||
void beginPrint( QPrinter& printer );
|
||||
/** Prepare the printer for printing in a PDF */
|
||||
void beginPrintAsPDF( QPrinter& printer, const QString& file );
|
||||
/** Print on a preconfigured printer */
|
||||
void doPrint( QPrinter& printer, QPainter& painter );
|
||||
|
||||
/**Print on a preconfigured printer
|
||||
* @param printer QPrinter destination
|
||||
* @painter QPainter source
|
||||
* @startNewPage set to true to begin the print on a new page
|
||||
*/
|
||||
void doPrint( QPrinter& printer, QPainter& painter, bool startNewPage = false );
|
||||
|
||||
/**Convenience function that prepares the printer and prints
|
||||
* @returns true if print was successful
|
||||
|
@ -1467,11 +1467,8 @@ void QgsComposer::exportCompositionAsPDF( QgsComposer::OutputMode mode )
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( featureI > 0 )
|
||||
{
|
||||
printer.newPage();
|
||||
}
|
||||
mComposition->doPrint( printer, painter );
|
||||
//start print on a new page if we're not on the first feature
|
||||
mComposition->doPrint( printer, painter, featureI > 0 );
|
||||
}
|
||||
}
|
||||
atlasMap->endRender();
|
||||
@ -1604,11 +1601,8 @@ void QgsComposer::printComposition( QgsComposer::OutputMode mode )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( i > 0 )
|
||||
{
|
||||
mPrinter.newPage();
|
||||
}
|
||||
mComposition->doPrint( mPrinter, painter );
|
||||
//start print on a new page if we're not on the first feature
|
||||
mComposition->doPrint( mPrinter, painter, i > 0 );
|
||||
}
|
||||
atlasMap->endRender();
|
||||
painter.end();
|
||||
|
@ -85,7 +85,33 @@ QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c )
|
||||
mGridResolutionSpinBox->setValue( mComposition->snapGridResolution() );
|
||||
mOffsetXSpinBox->setValue( mComposition->snapGridOffsetX() );
|
||||
mOffsetYSpinBox->setValue( mComposition->snapGridOffsetY() );
|
||||
|
||||
QgsAtlasComposition* atlas = &mComposition->atlasComposition();
|
||||
if ( atlas )
|
||||
{
|
||||
// repopulate data defined buttons if atlas layer changes
|
||||
connect( atlas, SIGNAL( coverageLayerChanged( QgsVectorLayer* ) ),
|
||||
this, SLOT( populateDataDefinedButtons() ) );
|
||||
connect( atlas, SIGNAL( toggled( bool ) ), this, SLOT( populateDataDefinedButtons() ) );
|
||||
}
|
||||
}
|
||||
|
||||
connect( mPaperSizeDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mPaperSizeDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mPaperSizeDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperSizeComboBox, SLOT( setDisabled( bool ) ) );
|
||||
connect( mPaperWidthDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mPaperWidthDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mPaperWidthDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperWidthDoubleSpinBox, SLOT( setDisabled( bool ) ) );
|
||||
connect( mPaperHeightDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mPaperHeightDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mPaperHeightDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperHeightDoubleSpinBox, SLOT( setDisabled( bool ) ) );
|
||||
connect( mNumPagesDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mNumPagesDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mNumPagesDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mNumPagesSpinBox, SLOT( setDisabled( bool ) ) );
|
||||
connect( mPaperOrientationDDBtn, SIGNAL( dataDefinedChanged( const QString& ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mPaperOrientationDDBtn, SIGNAL( dataDefinedActivated( bool ) ), this, SLOT( updateDataDefinedProperty( ) ) );
|
||||
connect( mPaperOrientationDDBtn, SIGNAL( dataDefinedActivated( bool ) ), mPaperOrientationComboBox, SLOT( setDisabled( bool ) ) );
|
||||
|
||||
blockSignals( false );
|
||||
}
|
||||
|
||||
@ -99,6 +125,103 @@ QgsCompositionWidget::~QgsCompositionWidget()
|
||||
|
||||
}
|
||||
|
||||
void QgsCompositionWidget::populateDataDefinedButtons()
|
||||
{
|
||||
if ( !mComposition )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsVectorLayer* vl = 0;
|
||||
QgsAtlasComposition* atlas = &mComposition->atlasComposition();
|
||||
|
||||
if ( atlas && atlas->enabled() )
|
||||
{
|
||||
vl = atlas->coverageLayer();
|
||||
}
|
||||
|
||||
mPaperSizeDDBtn->blockSignals( true );
|
||||
mPaperWidthDDBtn->blockSignals( true );
|
||||
mPaperHeightDDBtn->blockSignals( true );
|
||||
mNumPagesDDBtn->blockSignals( true );
|
||||
mPaperOrientationDDBtn->blockSignals( true );
|
||||
|
||||
mPaperSizeDDBtn->init( vl, mComposition->dataDefinedProperty( QgsComposerItem::PresetPaperSize ),
|
||||
QgsDataDefinedButton::String, QgsDataDefinedButton::paperSizeDesc() );
|
||||
mPaperWidthDDBtn->init( vl, mComposition->dataDefinedProperty( QgsComposerItem::PaperWidth ),
|
||||
QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
|
||||
mPaperHeightDDBtn->init( vl, mComposition->dataDefinedProperty( QgsComposerItem::PaperHeight ),
|
||||
QgsDataDefinedButton::Double, QgsDataDefinedButton::doublePosDesc() );
|
||||
mNumPagesDDBtn->init( vl, mComposition->dataDefinedProperty( QgsComposerItem::NumPages ),
|
||||
QgsDataDefinedButton::Int, QgsDataDefinedButton::intPosOneDesc() );
|
||||
mPaperOrientationDDBtn->init( vl, mComposition->dataDefinedProperty( QgsComposerItem::PaperOrientation ),
|
||||
QgsDataDefinedButton::String, QgsDataDefinedButton::paperOrientationDesc() );
|
||||
|
||||
//initial state of controls - disable related controls when dd buttons are active
|
||||
mPaperSizeComboBox->setEnabled( !mPaperSizeDDBtn->isActive() );
|
||||
|
||||
mPaperSizeDDBtn->blockSignals( false );
|
||||
mPaperWidthDDBtn->blockSignals( false );
|
||||
mPaperHeightDDBtn->blockSignals( false );
|
||||
mNumPagesDDBtn->blockSignals( false );
|
||||
mPaperOrientationDDBtn->blockSignals( false );
|
||||
}
|
||||
|
||||
void QgsCompositionWidget::setDataDefinedProperty( const QgsDataDefinedButton* ddBtn, QgsComposerItem::DataDefinedProperty property )
|
||||
{
|
||||
if ( !mComposition )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const QMap< QString, QString >& map = ddBtn->definedProperty();
|
||||
mComposition->setDataDefinedProperty( property, map.value( "active" ).toInt(), map.value( "useexpr" ).toInt(), map.value( "expression" ), map.value( "field" ) );
|
||||
}
|
||||
|
||||
QgsComposerItem::DataDefinedProperty QgsCompositionWidget::ddPropertyForWidget( QgsDataDefinedButton *widget )
|
||||
{
|
||||
if ( widget == mPaperSizeDDBtn )
|
||||
{
|
||||
return QgsComposerItem::PresetPaperSize;
|
||||
}
|
||||
else if ( widget == mPaperWidthDDBtn )
|
||||
{
|
||||
return QgsComposerItem::PaperWidth;
|
||||
}
|
||||
else if ( widget == mPaperHeightDDBtn )
|
||||
{
|
||||
return QgsComposerItem::PaperHeight;
|
||||
}
|
||||
else if ( widget == mNumPagesDDBtn )
|
||||
{
|
||||
return QgsComposerItem::NumPages;
|
||||
}
|
||||
else if ( widget == mPaperOrientationDDBtn )
|
||||
{
|
||||
return QgsComposerItem::PaperOrientation;
|
||||
}
|
||||
|
||||
return QgsComposerItem::NoProperty;
|
||||
}
|
||||
|
||||
void QgsCompositionWidget::updateDataDefinedProperty()
|
||||
{
|
||||
QgsDataDefinedButton* ddButton = dynamic_cast<QgsDataDefinedButton*>( sender() );
|
||||
if ( !ddButton || !mComposition )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsComposerItem::DataDefinedProperty property = ddPropertyForWidget( ddButton );
|
||||
if ( property == QgsComposerItem::NoProperty )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setDataDefinedProperty( ddButton, property );
|
||||
mComposition->refreshDataDefinedProperty( property );
|
||||
}
|
||||
|
||||
void QgsCompositionWidget::createPaperEntries()
|
||||
{
|
||||
QList<QgsCompositionPaper> formats;
|
||||
|
@ -15,10 +15,11 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "ui_qgscompositionwidgetbase.h"
|
||||
#include "qgscomposeritem.h"
|
||||
|
||||
class QgsComposition;
|
||||
class QgsComposerMap;
|
||||
class QgsComposerItem;
|
||||
class QgsDataDefinedButton;
|
||||
|
||||
/** \ingroup MapComposer
|
||||
* Struct to hold map composer paper properties.
|
||||
@ -76,6 +77,12 @@ class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase
|
||||
/* when a map is deleted */
|
||||
void onItemRemoved( QgsComposerItem* );
|
||||
|
||||
/**Must be called when a data defined button changes*/
|
||||
void updateDataDefinedProperty();
|
||||
|
||||
/**Initializes data defined buttons to current atlas coverage layer*/
|
||||
void populateDataDefinedButtons();
|
||||
|
||||
private:
|
||||
QgsComposition* mComposition;
|
||||
QMap<QString, QgsCompositionPaper> mPaperMap;
|
||||
@ -99,4 +106,11 @@ class QgsCompositionWidget: public QWidget, private Ui::QgsCompositionWidgetBase
|
||||
void setSize( QDoubleSpinBox *spin, double v );
|
||||
/**Blocks / unblocks the signals of all items*/
|
||||
void blockSignals( bool block );
|
||||
|
||||
/**Sets a data defined property for the item from its current data defined button settings*/
|
||||
void setDataDefinedProperty( const QgsDataDefinedButton *ddBtn, QgsComposerItem::DataDefinedProperty property );
|
||||
|
||||
/**Returns the data defined property corresponding to a data defined button widget*/
|
||||
virtual QgsComposerItem::DataDefinedProperty ddPropertyForWidget( QgsDataDefinedButton* widget );
|
||||
|
||||
};
|
||||
|
@ -98,6 +98,11 @@ void QgsComposition::init()
|
||||
mPreventCursorChange = false;
|
||||
|
||||
//data defined strings
|
||||
mDataDefinedNames.insert( QgsComposerItem::PresetPaperSize, QString( "dataDefinedPaperSize" ) );
|
||||
mDataDefinedNames.insert( QgsComposerItem::PaperWidth, QString( "dataDefinedPaperWidth" ) );
|
||||
mDataDefinedNames.insert( QgsComposerItem::PaperHeight, QString( "dataDefinedPaperHeight" ) );
|
||||
mDataDefinedNames.insert( QgsComposerItem::NumPages, QString( "dataDefinedNumPages" ) );
|
||||
mDataDefinedNames.insert( QgsComposerItem::PaperOrientation, QString( "dataDefinedPaperOrientation" ) );
|
||||
|
||||
//connect to atlas toggling on/off and coverage layer and feature changes
|
||||
//to update data defined values
|
||||
@ -213,7 +218,16 @@ void QgsComposition::setSelectedItem( QgsComposerItem *item )
|
||||
void QgsComposition::refreshDataDefinedProperty( QgsComposerItem::DataDefinedProperty property )
|
||||
{
|
||||
//updates data defined properties and redraws composition to match
|
||||
|
||||
if ( property == QgsComposerItem::NumPages || property == QgsComposerItem::AllProperties )
|
||||
{
|
||||
setNumPages( numPages() );
|
||||
}
|
||||
if ( property == QgsComposerItem::PaperWidth || property == QgsComposerItem::PaperHeight ||
|
||||
property == QgsComposerItem::PaperOrientation || property == QgsComposerItem::PresetPaperSize ||
|
||||
property == QgsComposerItem::AllProperties )
|
||||
{
|
||||
refreshPageSize();
|
||||
}
|
||||
}
|
||||
|
||||
QRectF QgsComposition::compositionBounds() const
|
||||
@ -303,7 +317,22 @@ double QgsComposition::paperWidth() const
|
||||
void QgsComposition::setNumPages( int pages )
|
||||
{
|
||||
int currentPages = numPages();
|
||||
int diff = pages - currentPages;
|
||||
int desiredPages = pages;
|
||||
|
||||
//data defined num pages set?
|
||||
QVariant exprVal;
|
||||
if ( dataDefinedEvaluate( QgsComposerItem::NumPages, exprVal, &mDataDefinedProperties ) )
|
||||
{
|
||||
bool ok = false;
|
||||
int pagesD = exprVal.toInt( &ok );
|
||||
QgsDebugMsg( QString( "exprVal NumPages:%1" ).arg( pagesD ) );
|
||||
if ( ok )
|
||||
{
|
||||
desiredPages = pagesD;
|
||||
}
|
||||
}
|
||||
|
||||
int diff = desiredPages - currentPages;
|
||||
if ( diff >= 0 )
|
||||
{
|
||||
for ( int i = 0; i < diff; ++i )
|
||||
@ -2466,6 +2495,8 @@ void QgsComposition::beginPrintAsPDF( QPrinter& printer, const QString& file )
|
||||
// https://bugreports.qt-project.org/browse/QTBUG-33583 - PDF output converts text to outline
|
||||
// Also an issue with PDF paper size using QPrinter::NativeFormat on Mac (always outputs portrait letter-size)
|
||||
printer.setOutputFormat( QPrinter::PdfFormat );
|
||||
printer.setOutputFileName( file );
|
||||
refreshPageSize();
|
||||
printer.setPaperSize( QSizeF( paperWidth(), paperHeight() ), QPrinter::Millimeter );
|
||||
|
||||
// TODO: add option for this in Composer
|
||||
@ -2482,9 +2513,13 @@ bool QgsComposition::exportAsPDF( const QString& file )
|
||||
return print( printer );
|
||||
}
|
||||
|
||||
void QgsComposition::doPrint( QPrinter& printer, QPainter& p )
|
||||
void QgsComposition::doPrint( QPrinter& printer, QPainter& p, bool startNewPage )
|
||||
{
|
||||
//QgsComposition starts page numbering at 0
|
||||
//set the page size again so that data defined page size takes effect
|
||||
refreshPageSize();
|
||||
printer.setPaperSize( QSizeF( paperWidth(), paperHeight() ), QPrinter::Millimeter );
|
||||
|
||||
//QgsComposition starts page numbering at 0
|
||||
int fromPage = ( printer.fromPage() < 1 ) ? 0 : printer.fromPage() - 1 ;
|
||||
int toPage = ( printer.toPage() < 1 ) ? numPages() - 1 : printer.toPage() - 1;
|
||||
|
||||
@ -2492,7 +2527,7 @@ void QgsComposition::doPrint( QPrinter& printer, QPainter& p )
|
||||
{
|
||||
for ( int i = fromPage; i <= toPage; ++i )
|
||||
{
|
||||
if ( i > fromPage )
|
||||
if ( i > fromPage || startNewPage )
|
||||
{
|
||||
printer.newPage();
|
||||
}
|
||||
@ -2510,7 +2545,7 @@ void QgsComposition::doPrint( QPrinter& printer, QPainter& p )
|
||||
{
|
||||
for ( int i = fromPage; i <= toPage; ++i )
|
||||
{
|
||||
if ( i > fromPage )
|
||||
if ( i > fromPage || startNewPage )
|
||||
{
|
||||
printer.newPage();
|
||||
}
|
||||
@ -2718,6 +2753,139 @@ bool QgsComposition::setAtlasMode( QgsComposition::AtlasMode mode )
|
||||
return true;
|
||||
}
|
||||
|
||||
void QgsComposition::refreshPageSize()
|
||||
{
|
||||
double pageWidth = mPageWidth;
|
||||
double pageHeight = mPageHeight;
|
||||
|
||||
QVariant exprVal;
|
||||
//in order of precedence - first consider predefined page size
|
||||
if ( dataDefinedEvaluate( QgsComposerItem::PresetPaperSize, exprVal, &mDataDefinedProperties ) )
|
||||
{
|
||||
QString presetString = exprVal.toString().trimmed();
|
||||
QgsDebugMsg( QString( "exprVal Paper Preset size :%1" ).arg( presetString ) );
|
||||
double widthD = 0;
|
||||
double heightD = 0;
|
||||
if ( decodePresetPaperSize( presetString, widthD, heightD ) )
|
||||
{
|
||||
pageWidth = widthD;
|
||||
pageHeight = heightD;
|
||||
}
|
||||
}
|
||||
|
||||
//which is overwritten by data defined width/height
|
||||
if ( dataDefinedEvaluate( QgsComposerItem::PaperWidth, exprVal, &mDataDefinedProperties ) )
|
||||
{
|
||||
bool ok;
|
||||
double widthD = exprVal.toDouble( &ok );
|
||||
QgsDebugMsg( QString( "exprVal Paper Width:%1" ).arg( widthD ) );
|
||||
if ( ok )
|
||||
{
|
||||
pageWidth = widthD;
|
||||
}
|
||||
}
|
||||
if ( dataDefinedEvaluate( QgsComposerItem::PaperHeight, exprVal, &mDataDefinedProperties ) )
|
||||
{
|
||||
bool ok;
|
||||
double heightD = exprVal.toDouble( &ok );
|
||||
QgsDebugMsg( QString( "exprVal Paper Height:%1" ).arg( heightD ) );
|
||||
if ( ok )
|
||||
{
|
||||
pageHeight = heightD;
|
||||
}
|
||||
}
|
||||
|
||||
//which is finally overwritten by data defined orientation
|
||||
if ( dataDefinedEvaluate( QgsComposerItem::PaperOrientation, exprVal, &mDataDefinedProperties ) )
|
||||
{
|
||||
bool ok;
|
||||
QString orientationString = exprVal.toString().trimmed();
|
||||
QgsComposition::PaperOrientation orientation = decodePaperOrientation( orientationString, ok );
|
||||
QgsDebugMsg( QString( "exprVal Paper Orientation:%1" ).arg( orientationString ) );
|
||||
if ( ok )
|
||||
{
|
||||
double heightD, widthD;
|
||||
switch ( orientation )
|
||||
{
|
||||
case QgsComposition::Portrait:
|
||||
{
|
||||
heightD = qMax( pageHeight, pageWidth );
|
||||
widthD = qMin( pageHeight, pageWidth );
|
||||
break;
|
||||
}
|
||||
case QgsComposition::Landscape:
|
||||
{
|
||||
heightD = qMin( pageHeight, pageWidth );
|
||||
widthD = qMax( pageHeight, pageWidth );
|
||||
break;
|
||||
}
|
||||
}
|
||||
pageWidth = widthD;
|
||||
pageHeight = heightD;
|
||||
}
|
||||
}
|
||||
|
||||
setPaperSize( pageWidth, pageHeight );
|
||||
}
|
||||
|
||||
QgsComposition::PaperOrientation QgsComposition::decodePaperOrientation( QString orientationString, bool &ok )
|
||||
{
|
||||
if ( orientationString.compare( "Portrait", Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
ok = true;
|
||||
return QgsComposition::Portrait;
|
||||
}
|
||||
if ( orientationString.compare( "Landscape", Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
ok = true;
|
||||
return QgsComposition::Landscape;
|
||||
}
|
||||
ok = false;
|
||||
return QgsComposition::Landscape; // default to landscape
|
||||
}
|
||||
|
||||
bool QgsComposition::decodePresetPaperSize( QString presetString, double &width, double &height )
|
||||
{
|
||||
QList< QPair< QString, QSizeF > > presets;
|
||||
presets << qMakePair( QString( "A5" ), QSizeF( 148, 210 ) );
|
||||
presets << qMakePair( QString( "A4" ), QSizeF( 210, 297 ) );
|
||||
presets << qMakePair( QString( "A3" ), QSizeF( 297, 420 ) );
|
||||
presets << qMakePair( QString( "A2" ), QSizeF( 420, 594 ) );
|
||||
presets << qMakePair( QString( "A1" ), QSizeF( 594, 841 ) );
|
||||
presets << qMakePair( QString( "A0" ), QSizeF( 841, 1189 ) );
|
||||
presets << qMakePair( QString( "B5" ), QSizeF( 176, 250 ) );
|
||||
presets << qMakePair( QString( "B4" ), QSizeF( 250, 353 ) );
|
||||
presets << qMakePair( QString( "B3" ), QSizeF( 353, 500 ) );
|
||||
presets << qMakePair( QString( "B2" ), QSizeF( 500, 707 ) );
|
||||
presets << qMakePair( QString( "B1" ), QSizeF( 707, 1000 ) );
|
||||
presets << qMakePair( QString( "B0" ), QSizeF( 1000, 1414 ) );
|
||||
// North american formats
|
||||
presets << qMakePair( QString( "Legal" ), QSizeF( 215.9, 355.6 ) );
|
||||
presets << qMakePair( QString( "ANSI A" ), QSizeF( 215.9, 279.4 ) );
|
||||
presets << qMakePair( QString( "ANSI B" ), QSizeF( 279.4, 431.8 ) );
|
||||
presets << qMakePair( QString( "ANSI C" ), QSizeF( 431.8, 558.8 ) );
|
||||
presets << qMakePair( QString( "ANSI D" ), QSizeF( 558.8, 863.6 ) );
|
||||
presets << qMakePair( QString( "ANSI E" ), QSizeF( 863.6, 1117.6 ) );
|
||||
presets << qMakePair( QString( "Arch A" ), QSizeF( 228.6, 304.8 ) );
|
||||
presets << qMakePair( QString( "Arch B" ), QSizeF( 304.8, 457.2 ) );
|
||||
presets << qMakePair( QString( "Arch C" ), QSizeF( 457.2, 609.6 ) );
|
||||
presets << qMakePair( QString( "Arch D" ), QSizeF( 609.6, 914.4 ) );
|
||||
presets << qMakePair( QString( "Arch E" ), QSizeF( 914.4, 1219.2 ) );
|
||||
presets << qMakePair( QString( "Arch E1" ), QSizeF( 762, 1066.8 ) );
|
||||
|
||||
QList< QPair< QString, QSizeF > >::const_iterator presetIt = presets.constBegin();
|
||||
for ( ;presetIt != presets.constEnd(); ++presetIt )
|
||||
{
|
||||
if ( presetString.compare(( *presetIt ).first, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
width = ( *presetIt ).second.width();
|
||||
height = ( *presetIt ).second.height();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QgsDataDefined *QgsComposition::dataDefinedProperty( QgsComposerItem::DataDefinedProperty property )
|
||||
{
|
||||
if ( property == QgsComposerItem::AllProperties || property == QgsComposerItem::NoProperty )
|
||||
@ -2932,6 +3100,7 @@ QVariant QgsComposition::dataDefinedValue( QgsComposerItem::DataDefinedProperty
|
||||
{
|
||||
dd = it.value();
|
||||
}
|
||||
|
||||
if ( !dd )
|
||||
{
|
||||
return QVariant();
|
||||
@ -3028,4 +3197,3 @@ double QgsComposition::relativePosition( double position, double beforeMin, doub
|
||||
//return linearly scaled position
|
||||
return m * position + c;
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,12 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
|
||||
ZValueAbove
|
||||
};
|
||||
|
||||
enum PaperOrientation
|
||||
{
|
||||
Portrait,
|
||||
Landscape
|
||||
};
|
||||
|
||||
//! @deprecated since 2.4 - use the constructor with QgsMapSettings
|
||||
Q_DECL_DEPRECATED QgsComposition( QgsMapRenderer* mapRenderer );
|
||||
explicit QgsComposition( const QgsMapSettings& mapSettings );
|
||||
@ -464,8 +470,13 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
|
||||
void beginPrint( QPrinter& printer );
|
||||
/** Prepare the printer for printing in a PDF */
|
||||
void beginPrintAsPDF( QPrinter& printer, const QString& file );
|
||||
/** Print on a preconfigured printer */
|
||||
void doPrint( QPrinter& printer, QPainter& painter );
|
||||
|
||||
/**Print on a preconfigured printer
|
||||
* @param printer QPrinter destination
|
||||
* @painter QPainter source
|
||||
* @startNewPage set to true to begin the print on a new page
|
||||
*/
|
||||
void doPrint( QPrinter& printer, QPainter& painter, bool startNewPage = false );
|
||||
|
||||
/**Convenience function that prepares the printer and prints
|
||||
* @returns true if print was successful
|
||||
@ -659,6 +670,15 @@ class CORE_EXPORT QgsComposition : public QGraphicsScene
|
||||
//tries to return the current QGraphicsView attached to the composition
|
||||
QGraphicsView* graphicsView() const;
|
||||
|
||||
/*Recalculates the page size using data defined page settings*/
|
||||
void refreshPageSize();
|
||||
|
||||
/*Decodes a string representing a paper orientation*/
|
||||
QgsComposition::PaperOrientation decodePaperOrientation( QString orientationString, bool &ok );
|
||||
|
||||
/*Decodes a string representing a preset page size*/
|
||||
bool decodePresetPaperSize( QString presetString, double &width, double &height );
|
||||
|
||||
/**Evaluate a data defined property and return the calculated value
|
||||
* @returns true if data defined property could be successfully evaluated
|
||||
* @param property data defined property to evaluate
|
||||
|
@ -692,7 +692,7 @@ QString QgsDataDefinedButton::blendModesDesc()
|
||||
{
|
||||
return trString() + QString( "[<b>Normal</b>|<b>Lighten</b>|<b>Screen</b>|<b>Dodge</b>|<br>"
|
||||
"<b>Addition</b>|<b>Darken</b>|<b>Multiply</b>|<b>Burn</b>|<b>Overlay</b>|<br>"
|
||||
"<b>SoftLight</b>|<b>HardLight</b>|<b>Difference</b>|<b>Subtract</b>" );
|
||||
"<b>SoftLight</b>|<b>HardLight</b>|<b>Difference</b>|<b>Subtract</b>]" );
|
||||
}
|
||||
|
||||
QString QgsDataDefinedButton::svgPathDesc()
|
||||
@ -701,3 +701,17 @@ QString QgsDataDefinedButton::svgPathDesc()
|
||||
"<b>''</b>=empty|absolute|search-paths-relative|<br>"
|
||||
"project-relative|URL" );
|
||||
}
|
||||
|
||||
QString QgsDataDefinedButton::paperSizeDesc()
|
||||
{
|
||||
return trString() + QString( "[<b>A5</b>|<b>A4</b>|<b>A3</b>|<b>A2</b>|<b>A1</b>|<b>A0</b>"
|
||||
"<b>B5</b>|<b>B4</b>|<b>B3</b>|<b>B2</b>|<b>B1</b>|<b>B0</b>"
|
||||
"<b>Legal</b>|<b>Ansi A</b>|<b>Ansi B</b>|<b>Ansi C</b>|<b>Ansi D</b>|<b>Ansi E</b>"
|
||||
"<b>Arch A</b>|<b>Arch B</b>|<b>Arch C</b>|<b>Arch D</b>|<b>Arch E</b>|<b>Arch E1</b>]"
|
||||
);
|
||||
}
|
||||
|
||||
QString QgsDataDefinedButton::paperOrientationDesc()
|
||||
{
|
||||
return trString() + QString( "[<b>portrait</b>|<b>landscape</b>]" );
|
||||
}
|
||||
|
@ -191,6 +191,8 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton
|
||||
static QString penJoinStyleDesc();
|
||||
static QString blendModesDesc();
|
||||
static QString svgPathDesc();
|
||||
static QString paperSizeDesc();
|
||||
static QString paperOrientationDesc();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
|
@ -65,12 +65,6 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<property name="labelAlignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="textLabel3">
|
||||
<property name="text">
|
||||
@ -85,17 +79,28 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="mPaperSizeComboBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="mPaperSizeComboBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsDataDefinedButton" name="mPaperSizeDDBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
@ -108,23 +113,34 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="mPaperWidthDoubleSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>99999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="mPaperWidthDoubleSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>99999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsDataDefinedButton" name="mPaperWidthDDBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
@ -137,23 +153,34 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="mPaperHeightDoubleSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>99999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="mPaperHeightDoubleSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>99999.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsDataDefinedButton" name="mPaperHeightDDBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
@ -189,11 +216,22 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="mNumPagesSpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="mNumPagesSpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsDataDefinedButton" name="mNumPagesDDBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="textLabel7">
|
||||
@ -209,15 +247,47 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="mPaperOrientationComboBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QComboBox" name="mPaperOrientationComboBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsDataDefinedButton" name="mPaperOrientationDDBtn">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Page background</string>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QPushButton" name="mPageStyleButton">
|
||||
<property name="text">
|
||||
<string>Change...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Export resolution</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -234,14 +304,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Export resolution</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" colspan="2">
|
||||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="mPrintAsRasterCheckBox">
|
||||
<property name="text">
|
||||
<string>Print as raster</string>
|
||||
@ -254,7 +317,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QCheckBox" name="mGenerateWorldFileCheckBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
@ -267,7 +330,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QComboBox" name="mWorldFileMapComboBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
@ -277,20 +340,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QPushButton" name="mPageStyleButton">
|
||||
<property name="text">
|
||||
<string>Change...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Page background</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -428,6 +477,11 @@
|
||||
<header location="global">qgscollapsiblegroupbox.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsDataDefinedButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>qgsdatadefinedbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
|
Loading…
x
Reference in New Issue
Block a user