16 #ifndef QGSCOMPOSITION_H
17 #define QGSCOMPOSITION_H
21 #include <QDomDocument>
22 #include <QGraphicsScene>
23 #include <QLinkedList>
42 class QGraphicsRectItem;
127 void setPaperSize(
const double width,
const double height );
134 double paperHeight()
const;
141 double paperWidth()
const;
152 void setNumPages(
const int pages );
158 int numPages()
const;
169 bool pageIsEmpty(
const int page )
const;
178 bool shouldExportPage(
const int page )
const;
188 QPointF positionOnPage(
const QPointF & position )
const;
193 int pageNumberForPoint(
const QPointF & position )
const;
198 void setStatusMessage(
const QString & message );
203 void updateSettings();
205 void setSnapToGridEnabled(
const bool b );
208 void setGridVisible(
const bool b );
212 void setSnapLinesVisible(
const bool visible );
222 void clearSnapLines();
224 void setSnapGridResolution(
const double r );
227 void setSnapGridOffsetX(
const double offset );
230 void setSnapGridOffsetY(
const double offset );
233 void setGridPen(
const QPen& p );
234 const QPen&
gridPen()
const {
return mGridPen;}
236 void setGridStyle(
const GridStyle s );
292 void setBoundingBoxesVisible(
const bool boundsVisible );
309 QgsComposerItem* composerItemAt(
const QPointF & position,
const bool ignoreLocked =
false )
const;
320 int pageNumberAt(
const QPointF& position )
const;
329 QList<QgsComposerItem*> selectedComposerItems(
const bool includeLockedItems =
true );
334 QList<const QgsComposerMap*> composerMapItems()
const;
340 template<
class T>
void composerItems( QList<T*>& itemList );
348 template<
class T>
void composerItemsOnPage( QList<T*>& itemList,
const int pageNumber )
const;
367 const QgsComposerItem* getComposerItemById(
const QString theId )
const;
372 const QgsComposerItem* getComposerItemByUuid(
const QString theUuid )
const;
375 void setPrintResolution(
const int dpi );
389 void setUseAdvancedEffects(
const bool effectsEnabled );
406 Q_DECL_DEPRECATED
int pixelFontSize(
double pointSize )
const;
411 Q_DECL_DEPRECATED
double pointFontSize(
int pixelSize )
const;
414 bool writeXML( QDomElement& composerElem, QDomDocument& doc );
417 bool readXML(
const QDomElement& compositionElem,
const QDomDocument& doc );
427 bool loadFromTemplate(
const QDomDocument& doc, QMap<QString, QString>* substitutionMap = 0,
428 bool addUndoCommands =
false,
const bool clearComposition =
true );
439 void addItemsFromXML(
const QDomElement& elem,
const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore = 0,
440 bool addUndoCommands =
false, QPointF* pos = 0,
bool pasteInPlace =
false );
448 void raiseSelectedItems();
452 void lowerSelectedItems();
455 void moveSelectedItemsToTop();
458 void moveSelectedItemsToBottom();
463 void selectNextByZOrder(
const ZValueDirection direction );
468 void alignSelectedItemsLeft();
469 void alignSelectedItemsHCenter();
470 void alignSelectedItemsRight();
471 void alignSelectedItemsTop();
472 void alignSelectedItemsVCenter();
473 void alignSelectedItemsBottom();
477 void lockSelectedItems();
479 void unlockAllItems();
509 QPointF snapPointToGrid(
const QPointF& scenePoint )
const;
512 QList< QGraphicsLineItem* >*
snapLines() {
return &mSnapLines;}
520 QGraphicsLineItem* addSnapLine();
522 void removeSnapLine( QGraphicsLineItem* line );
526 QGraphicsLineItem* nearestSnapLine(
const bool horizontal,
const double x,
const double y,
const double tolerance, QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >& snappedItems )
const;
537 void cancelCommand();
540 void endMultiFrameCommand();
542 void cancelMultiFrameCommand();
554 void addComposerMap(
QgsComposerMap* map,
const bool setDefaultPreviewStyle =
true );
571 void removeComposerItem(
QgsComposerItem* item,
const bool createCommand =
true,
const bool removeGroupItems =
true );
584 void beginPrint( QPrinter& printer,
const bool evaluateDDPageSize =
false );
586 void beginPrintAsPDF( QPrinter& printer,
const QString&
file );
593 void doPrint( QPrinter& printer, QPainter& painter,
bool startNewPage =
false );
598 bool print( QPrinter &printer,
const bool evaluateDDPageSize =
false );
603 bool exportAsPDF(
const QString&
file );
607 QImage printPageAsRaster(
int page );
612 void renderPage( QPainter* p,
int page );
615 void computeWorldFileParameters(
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
622 Q_DECL_DEPRECATED
static void relativeResizeRect( QRectF& rectToResize,
const QRectF& boundsBefore,
const QRectF& boundsAfter );
627 Q_DECL_DEPRECATED
static double relativePosition(
double position,
double beforeMin,
double beforeMax,
double afterMin,
double afterMax );
645 QList< QgsPaperItem* >
pages() {
return mPages; }
693 void setAllUnselected();
716 QList< QgsPaperItem* > mPages;
717 double mSpaceBetweenPages;
721 void createDefaultPageStyleSymbol();
724 QSet<QgsComposerMultiFrame*> mMultiFrames;
727 int mPrintResolution;
733 bool mGenerateWorldFile;
738 bool mUseAdvancedEffects;
743 double mSnapGridResolution;
744 double mSnapGridOffsetX;
745 double mSnapGridOffsetY;
747 GridStyle mGridStyle;
756 QList< QGraphicsLineItem* > mSnapLines;
758 bool mBoundingBoxesVisible;
761 QUndoStack* mUndoStack;
771 bool mPreventCursorChange;
776 QMap< QgsComposerObject::DataDefinedProperty, QString > mDataDefinedNames;
778 QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* > mDataDefinedProperties;
783 QRectF compositionBounds()
const;
786 void updateZValues(
const bool addUndoCommands =
true );
790 int boundingRectOfSelectedItems( QRectF& bRect );
799 QPointF minPointFromXml(
const QDomElement& elem )
const;
803 void updatePaperItems();
805 void removePaperItems();
806 void deleteAndRemoveMultiFrames();
808 static QString encodeStringForXML(
const QString& str );
811 QGraphicsView* graphicsView()
const;
814 void refreshPageSize();
824 QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* >* dataDefinedProperties );
832 const QMap<QgsComposerObject::DataDefinedProperty, QgsDataDefined *> *dataDefinedProperties )
const;
842 QMap<QgsComposerObject::DataDefinedProperty, QgsDataDefined *> *dataDefinedProperties )
const;
850 void prepareDataDefinedExpression(
QgsDataDefined *dd, QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* >* dataDefinedProperties )
const;
856 bool ddPageSizeActive()
const;
860 void prepareAllDataDefinedExpressions();
863 void paperSizeChanged();
864 void nPagesChanged();
867 void printResolutionChanged();
895 void refreshItemsTriggered();
898 void statusMsgChanged( QString message );
907 QList<QGraphicsItem *> graphicsItemList = items();
908 QList<QGraphicsItem *>::iterator itemIt = graphicsItemList.begin();
909 for ( ; itemIt != graphicsItemList.end(); ++itemIt )
911 T* item =
dynamic_cast<T*
>( *itemIt );
914 itemList.push_back( item );
922 QList<QGraphicsItem *> graphicsItemList = items();
923 QList<QGraphicsItem *>::iterator itemIt = graphicsItemList.begin();
924 for ( ; itemIt != graphicsItemList.end(); ++itemIt )
926 T* item =
dynamic_cast<T*
>( *itemIt );
929 itemList.push_back( item );