Skip to content
Permalink
Browse files
API Tidy ups for composer
git-svn-id: http://svn.osgeo.org/qgis/trunk@9570 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Nov 7, 2008
1 parent f123e65 commit e5d6287c964eb64676d76f9decd3612c479777be
@@ -456,7 +456,7 @@ void QgsComposer::on_mActionPrint_activated( void )
//set user-defined resolution
if ( mComposition )
{
printer.setResolution( mComposition->printoutResolution() );
printer.setResolution( mComposition->printResolution() );
}
QPainter p( &printer );

@@ -489,8 +489,8 @@ void QgsComposer::on_mActionExportAsImage_activated( void )
}

// Image size
int width = ( int )( mComposition->printoutResolution() * mComposition->paperWidth() / 25.4 );
int height = ( int )( mComposition-> printoutResolution() * mComposition->paperHeight() / 25.4 );
int width = ( int )( mComposition->printResolution() * mComposition->paperWidth() / 25.4 );
int height = ( int )( mComposition-> printResolution() * mComposition->paperHeight() / 25.4 );

int memuse = width * height * 3 / 1000000; // pixmap + image
QgsDebugMsg( QString( "Image %1 x %2" ).arg( width ).arg( height ) );
@@ -592,8 +592,8 @@ void QgsComposer::on_mActionExportAsImage_activated( void )
mView->setScene( 0 );

QImage image( QSize( width, height ), QImage::Format_ARGB32 );
image.setDotsPerMeterX( mComposition->printoutResolution() / 25.4 * 1000 );
image.setDotsPerMeterY( mComposition->printoutResolution() / 25.4 * 1000 );
image.setDotsPerMeterX( mComposition->printResolution() / 25.4 * 1000 );
image.setDotsPerMeterY( mComposition->printResolution() / 25.4 * 1000 );
image.fill( 0 );
QPainter p( &image );
QRectF sourceArea( 0, 0, mComposition->paperWidth(), mComposition->paperHeight() );
@@ -41,7 +41,7 @@ QgsCompositionWidget::QgsCompositionWidget( QWidget* parent, QgsComposition* c )
//read printout resolution from composition
if ( mComposition )
{
mResolutionLineEdit->setText( QString::number( mComposition->printoutResolution() ) );
mResolutionLineEdit->setText( QString::number( mComposition->printResolution() ) );
}
}

@@ -281,12 +281,12 @@ void QgsCompositionWidget::on_mResolutionLineEdit_textChanged( const QString& te
int resolution = text.toInt( &conversionOk );
if ( conversionOk && mComposition )
{
mComposition->setPrintoutResolution( resolution );
mComposition->setPrintResolution( resolution );
}
else if ( mComposition )
{
//set screen resolution per default
QPrinter resolutionInfo( QPrinter::ScreenResolution );
mComposition->setPrintoutResolution( resolutionInfo.resolution() );
mComposition->setPrintResolution( resolutionInfo.resolution() );
}
}
@@ -210,15 +210,15 @@ void QgsComposerScaleBar::setStyle( const QString& styleName )
QgsTicksScaleBarStyle* tickStyle = new QgsTicksScaleBarStyle( this );
if ( styleName == tr( "Line Ticks Middle" ) )
{
tickStyle->setTickPosition( QgsTicksScaleBarStyle::MIDDLE );
tickStyle->setTickPosition( QgsTicksScaleBarStyle::TicksMiddle );
}
else if ( styleName == tr( "Line Ticks Down" ) )
{
tickStyle->setTickPosition( QgsTicksScaleBarStyle::DOWN );
tickStyle->setTickPosition( QgsTicksScaleBarStyle::TicksDown );
}
else if ( styleName == tr( "Line Ticks Up" ) )
{
tickStyle->setTickPosition( QgsTicksScaleBarStyle::UP );
tickStyle->setTickPosition( QgsTicksScaleBarStyle::TicksUp );
}
mStyle = tickStyle;
}
@@ -30,7 +30,7 @@ QgsComposition::QgsComposition( QgsMapRenderer* mapRenderer ): QGraphicsScene( 0
mPaperItem->setBrush( Qt::white );
addItem( mPaperItem );
mPaperItem->setZValue( 0 );
mPrintoutResolution = 300; //hardcoded default
mPrintResolution = 300; //hardcoded default
}

QgsComposition::QgsComposition(): QGraphicsScene( 0 ), mMapRenderer( 0 ), mPlotStyle( QgsComposition::Preview ), mPaperItem( 0 )
@@ -69,8 +69,8 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
@return id or 0 pointer if the composer map item does not exist*/
const QgsComposerMap* getComposerMapById( int id ) const;

int printoutResolution() const {return mPrintoutResolution;}
void setPrintoutResolution( int dpi ) {mPrintoutResolution = dpi;}
int printResolution() const {return mPrintResolution;}
void setPrintResolution( int dpi ) {mPrintResolution = dpi;}

/**Returns pointer to map renderer of qgis map canvas*/
QgsMapRenderer* mapRenderer() {return mMapRenderer;}
@@ -121,7 +121,7 @@ class CORE_EXPORT QgsComposition: public QGraphicsScene
QLinkedList<QgsComposerItem*> mItemZList;

/**Dpi for printout*/
int mPrintoutResolution;
int mPrintResolution;

QgsComposition(); //default constructor is forbidden

@@ -20,12 +20,12 @@

QgsTicksScaleBarStyle::QgsTicksScaleBarStyle( const QgsComposerScaleBar* bar ): QgsScaleBarStyle( bar )
{
mTickPosition = MIDDLE;
mTickPosition = TicksMiddle;
}

QgsTicksScaleBarStyle::QgsTicksScaleBarStyle(): QgsScaleBarStyle( 0 )
{
mTickPosition = MIDDLE;
mTickPosition = TicksMiddle;
}

QgsTicksScaleBarStyle::~QgsTicksScaleBarStyle()
@@ -37,11 +37,11 @@ QString QgsTicksScaleBarStyle::name() const
{
switch ( mTickPosition )
{
case UP:
case TicksUp:
return "Line Ticks Up";
case DOWN:
case TicksDown:
return "Line Ticks Down";
case MIDDLE:
case TicksMiddle:
return "Line Ticks Middle";
}
return ""; // to make gcc happy
@@ -69,13 +69,13 @@ void QgsTicksScaleBarStyle::draw( QPainter* p, double xOffset ) const
p->drawLine( segmentIt->first + xOffset, barTopPosition, segmentIt->first + xOffset, barTopPosition + mScaleBar->height() );
switch ( mTickPosition )
{
case DOWN:
case TicksDown:
p->drawLine( xOffset + segmentIt->first, barTopPosition, xOffset + segmentIt->first + mScaleBar->segmentMillimeters(), barTopPosition );
break;
case MIDDLE:
case TicksMiddle:
p->drawLine( xOffset + segmentIt->first, middlePosition, xOffset + segmentIt->first + mScaleBar->segmentMillimeters(), middlePosition );
break;
case UP:
case TicksUp:
p->drawLine( xOffset + segmentIt->first, bottomPosition, xOffset + segmentIt->first + mScaleBar->segmentMillimeters(), bottomPosition );
break;
}
@@ -27,9 +27,9 @@ class CORE_EXPORT QgsTicksScaleBarStyle: public QgsScaleBarStyle
public:
enum TickPosition
{
UP,
DOWN,
MIDDLE
TicksUp,
TicksDown,
TicksMiddle
};

QgsTicksScaleBarStyle( const QgsComposerScaleBar* bar );

0 comments on commit e5d6287

Please sign in to comment.