-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9630a39
commit edecc37
Showing
20 changed files
with
412 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutexporter.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
class QgsLayoutExporter | ||
{ | ||
%Docstring | ||
Handles rendering and exports of layouts to various formats. | ||
.. versionadded:: 3.0 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslayoutexporter.h" | ||
%End | ||
public: | ||
|
||
QgsLayoutExporter( QgsLayout *layout ); | ||
%Docstring | ||
Constructor for QgsLayoutExporter, for the specified ``layout``. | ||
%End | ||
|
||
void renderPage( QPainter *painter, int page ); | ||
%Docstring | ||
Renders a full page to a destination ``painter``. | ||
|
||
The ``page`` argument specifies the page number to render. Page numbers | ||
are 0 based, such that the first page in a layout is page 0. | ||
|
||
.. seealso:: renderRect() | ||
%End | ||
|
||
void renderRegion( QPainter *painter, const QRectF ®ion ); | ||
%Docstring | ||
Renders a ``region`` from the layout to a ``painter``. This method can be used | ||
to render sections of pages rather than full pages. | ||
|
||
.. seealso:: renderPage() | ||
%End | ||
|
||
}; | ||
|
||
|
||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/layout/qgslayoutexporter.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*************************************************************************** | ||
qgslayoutexporter.cpp | ||
------------------- | ||
begin : October 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgslayoutexporter.h" | ||
#include "qgslayout.h" | ||
|
||
QgsLayoutExporter::QgsLayoutExporter( QgsLayout *layout ) | ||
: mLayout( layout ) | ||
{ | ||
|
||
} | ||
|
||
void QgsLayoutExporter::renderPage( QPainter *painter, int page ) | ||
{ | ||
if ( !mLayout ) | ||
return; | ||
|
||
if ( mLayout->pageCollection()->pageCount() <= page || page < 0 ) | ||
{ | ||
return; | ||
} | ||
|
||
QgsLayoutItemPage *pageItem = mLayout->pageCollection()->page( page ); | ||
if ( !pageItem ) | ||
{ | ||
return; | ||
} | ||
|
||
QRectF paperRect = QRectF( pageItem->pos().x(), pageItem->pos().y(), pageItem->rect().width(), pageItem->rect().height() ); | ||
renderRegion( painter, paperRect ); | ||
} | ||
|
||
void QgsLayoutExporter::renderRegion( QPainter *painter, const QRectF ®ion ) | ||
{ | ||
QPaintDevice *paintDevice = painter->device(); | ||
if ( !paintDevice || !mLayout ) | ||
{ | ||
return; | ||
} | ||
|
||
#if 0 //TODO | ||
setSnapLinesVisible( false ); | ||
#endif | ||
|
||
mLayout->render( painter, QRectF( 0, 0, paintDevice->width(), paintDevice->height() ), region ); | ||
|
||
#if 0 // TODO | ||
setSnapLinesVisible( true ); | ||
#endif | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/*************************************************************************** | ||
qgslayoutexporter.h | ||
------------------- | ||
begin : October 2017 | ||
copyright : (C) 2017 by Nyall Dawson | ||
email : nyall dot dawson at gmail dot com | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSLAYOUTEXPORTER_H | ||
#define QGSLAYOUTEXPORTER_H | ||
|
||
#include "qgis_core.h" | ||
#include <QPointer> | ||
|
||
class QgsLayout; | ||
class QPainter; | ||
|
||
/** | ||
* \ingroup core | ||
* \class QgsLayoutExporter | ||
* \brief Handles rendering and exports of layouts to various formats. | ||
* \since QGIS 3.0 | ||
*/ | ||
class CORE_EXPORT QgsLayoutExporter | ||
{ | ||
|
||
public: | ||
|
||
/** | ||
* Constructor for QgsLayoutExporter, for the specified \a layout. | ||
*/ | ||
QgsLayoutExporter( QgsLayout *layout ); | ||
|
||
/** | ||
* Renders a full page to a destination \a painter. | ||
* | ||
* The \a page argument specifies the page number to render. Page numbers | ||
* are 0 based, such that the first page in a layout is page 0. | ||
* | ||
* \see renderRect() | ||
*/ | ||
void renderPage( QPainter *painter, int page ); | ||
|
||
/** | ||
* Renders a \a region from the layout to a \a painter. This method can be used | ||
* to render sections of pages rather than full pages. | ||
* | ||
* \see renderPage() | ||
*/ | ||
void renderRegion( QPainter *painter, const QRectF ®ion ); | ||
|
||
private: | ||
|
||
QPointer< QgsLayout > mLayout; | ||
}; | ||
|
||
#endif //QGSLAYOUTEXPORTER_H | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.