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 );
295 QgsComposerItem* composerItemAt(
const QPointF & position,
const bool ignoreLocked =
false )
const;
306 int pageNumberAt(
const QPointF& position )
const;
315 QList<QgsComposerItem*> selectedComposerItems(
const bool includeLockedItems =
true );
320 QList<const QgsComposerMap*> composerMapItems()
const;
326 template<
class T>
void composerItems( QList<T*>& itemList );
334 template<
class T>
void composerItemsOnPage( QList<T*>& itemList,
const int pageNumber )
const;
353 const QgsComposerItem* getComposerItemById(
const QString theId )
const;
358 const QgsComposerItem* getComposerItemByUuid(
const QString theUuid )
const;
361 void setPrintResolution(
const int dpi );
376 void setUseAdvancedEffects(
const bool effectsEnabled );
393 Q_DECL_DEPRECATED
int pixelFontSize(
double pointSize )
const;
398 Q_DECL_DEPRECATED
double pointFontSize(
int pixelSize )
const;
401 bool writeXML( QDomElement& composerElem, QDomDocument& doc );
404 bool readXML(
const QDomElement& compositionElem,
const QDomDocument& doc );
414 bool loadFromTemplate(
const QDomDocument& doc, QMap<QString, QString>* substitutionMap = 0,
415 bool addUndoCommands =
false,
const bool clearComposition =
true );
426 void addItemsFromXML(
const QDomElement& elem,
const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore = 0,
427 bool addUndoCommands =
false, QPointF* pos = 0,
bool pasteInPlace =
false );
435 void raiseSelectedItems();
439 void lowerSelectedItems();
442 void moveSelectedItemsToTop();
445 void moveSelectedItemsToBottom();
450 void selectNextByZOrder(
const ZValueDirection direction );
455 void alignSelectedItemsLeft();
456 void alignSelectedItemsHCenter();
457 void alignSelectedItemsRight();
458 void alignSelectedItemsTop();
459 void alignSelectedItemsVCenter();
460 void alignSelectedItemsBottom();
464 void lockSelectedItems();
466 void unlockAllItems();
496 QPointF snapPointToGrid(
const QPointF& scenePoint )
const;
499 QList< QGraphicsLineItem* >*
snapLines() {
return &mSnapLines;}
507 QGraphicsLineItem* addSnapLine();
509 void removeSnapLine( QGraphicsLineItem* line );
513 QGraphicsLineItem* nearestSnapLine(
const bool horizontal,
const double x,
const double y,
const double tolerance, QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >& snappedItems )
const;
524 void cancelCommand();
527 void endMultiFrameCommand();
529 void cancelMultiFrameCommand();
541 void addComposerMap(
QgsComposerMap* map,
const bool setDefaultPreviewStyle =
true );
558 void removeComposerItem(
QgsComposerItem* item,
const bool createCommand =
true,
const bool removeGroupItems =
true );
571 void beginPrint( QPrinter& printer,
const bool evaluateDDPageSize =
false );
573 void beginPrintAsPDF( QPrinter& printer,
const QString&
file );
580 void doPrint( QPrinter& printer, QPainter& painter,
bool startNewPage =
false );
585 bool print( QPrinter &printer,
const bool evaluateDDPageSize =
false );
590 bool exportAsPDF(
const QString&
file );
594 QImage printPageAsRaster(
int page );
599 void renderPage( QPainter* p,
int page );
602 void computeWorldFileParameters(
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
609 Q_DECL_DEPRECATED
static void relativeResizeRect( QRectF& rectToResize,
const QRectF& boundsBefore,
const QRectF& boundsAfter );
614 Q_DECL_DEPRECATED
static double relativePosition(
double position,
double beforeMin,
double beforeMax,
double afterMin,
double afterMax );
632 QList< QgsPaperItem* >
pages() {
return mPages; }
680 void setAllUnselected();
703 QList< QgsPaperItem* > mPages;
704 double mSpaceBetweenPages;
708 void createDefaultPageStyleSymbol();
711 QSet<QgsComposerMultiFrame*> mMultiFrames;
714 int mPrintResolution;
720 bool mGenerateWorldFile;
725 bool mUseAdvancedEffects;
730 double mSnapGridResolution;
731 double mSnapGridOffsetX;
732 double mSnapGridOffsetY;
734 GridStyle mGridStyle;
743 QList< QGraphicsLineItem* > mSnapLines;
747 QUndoStack* mUndoStack;
757 bool mPreventCursorChange;
762 QMap< QgsComposerObject::DataDefinedProperty, QString > mDataDefinedNames;
764 QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* > mDataDefinedProperties;
769 QRectF compositionBounds()
const;
772 void updateZValues(
const bool addUndoCommands =
true );
776 int boundingRectOfSelectedItems( QRectF& bRect );
785 QPointF minPointFromXml(
const QDomElement& elem )
const;
789 void updatePaperItems();
791 void removePaperItems();
792 void deleteAndRemoveMultiFrames();
794 static QString encodeStringForXML(
const QString& str );
797 QGraphicsView* graphicsView()
const;
800 void refreshPageSize();
810 QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* >* dataDefinedProperties );
818 const QMap<QgsComposerObject::DataDefinedProperty, QgsDataDefined *> *dataDefinedProperties )
const;
828 QMap<QgsComposerObject::DataDefinedProperty, QgsDataDefined *> *dataDefinedProperties )
const;
836 void prepareDataDefinedExpression(
QgsDataDefined *dd, QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* >* dataDefinedProperties )
const;
842 bool ddPageSizeActive()
const;
846 void prepareAllDataDefinedExpressions();
849 void paperSizeChanged();
850 void nPagesChanged();
853 void printResolutionChanged();
881 void refreshItemsTriggered();
884 void statusMsgChanged( QString message );
893 QList<QGraphicsItem *> graphicsItemList = items();
894 QList<QGraphicsItem *>::iterator itemIt = graphicsItemList.begin();
895 for ( ; itemIt != graphicsItemList.end(); ++itemIt )
897 T* item =
dynamic_cast<T*
>( *itemIt );
900 itemList.push_back( item );
908 QList<QGraphicsItem *> graphicsItemList = items();
909 QList<QGraphicsItem *>::iterator itemIt = graphicsItemList.begin();
910 for ( ; itemIt != graphicsItemList.end(); ++itemIt )
912 T* item =
dynamic_cast<T*
>( *itemIt );
915 itemList.push_back( item );