16 #ifndef QGSCOMPOSITION_H
17 #define QGSCOMPOSITION_H
22 #include <QDomDocument>
23 #include <QGraphicsScene>
24 #include <QLinkedList>
40 class QGraphicsRectItem;
105 void setPaperSize(
double width,
double height );
108 double paperHeight()
const;
111 double paperWidth()
const;
116 void setNumPages(
int pages );
118 int numPages()
const;
128 QPointF positionOnPage(
const QPointF & position )
const;
133 int pageNumberForPoint(
const QPointF & position )
const;
138 void setStatusMessage(
const QString & message );
142 void updateSettings();
144 void setSnapToGridEnabled(
bool b );
147 void setGridVisible(
bool b );
151 void setSnapLinesVisible(
bool visible );
161 void clearSnapLines();
163 void setSnapGridResolution(
double r );
166 void setSnapGridTolerance(
double tolerance );
169 void setSnapGridOffsetX(
double offset );
172 void setSnapGridOffsetY(
double offset );
175 void setGridPen(
const QPen& p );
176 const QPen&
gridPen()
const {
return mGridPen;}
178 void setGridStyle( GridStyle s );
196 int pageNumberAt(
const QPointF& position )
const;
201 QList<QgsComposerItem*> selectedComposerItems();
206 QList<const QgsComposerMap*> composerMapItems()
const;
211 template<
class T>
void composerItems( QList<T*>& itemList );
257 void setUseAdvancedEffects(
bool effectsEnabled );
268 int pixelFontSize(
double pointSize )
const;
271 double pointFontSize(
int pixelSize )
const;
274 bool writeXML( QDomElement& composerElem, QDomDocument& doc );
277 bool readXML(
const QDomElement& compositionElem,
const QDomDocument& doc );
284 bool loadFromTemplate(
const QDomDocument& doc, QMap<QString, QString>* substitutionMap = 0,
bool addUndoCommands =
false );
295 void addItemsFromXML(
const QDomElement& elem,
const QDomDocument& doc, QMap< QgsComposerMap*, int >* mapsToRestore = 0,
296 bool addUndoCommands =
false, QPointF* pos = 0,
bool pasteInPlace =
false );
304 void raiseSelectedItems();
306 void lowerSelectedItems();
308 void moveSelectedItemsToTop();
310 void moveSelectedItemsToBottom();
314 void selectNextByZOrder( ZValueDirection direction );
319 void alignSelectedItemsLeft();
320 void alignSelectedItemsHCenter();
321 void alignSelectedItemsRight();
322 void alignSelectedItemsTop();
323 void alignSelectedItemsVCenter();
324 void alignSelectedItemsBottom();
328 void lockSelectedItems();
330 void unlockAllItems();
340 QPointF snapPointToGrid(
const QPointF& scenePoint )
const;
343 QList< QGraphicsLineItem* >*
snapLines() {
return &mSnapLines;}
351 QGraphicsLineItem* addSnapLine();
353 void removeSnapLine( QGraphicsLineItem* line );
357 QGraphicsLineItem* nearestSnapLine(
bool horizontal,
double x,
double y,
double tolerance, QList< QPair< QgsComposerItem*, QgsComposerItem::ItemPositionMode > >& snappedItems );
368 void cancelCommand();
371 void endMultiFrameCommand();
383 void addComposerMap(
QgsComposerMap* map,
bool setDefaultPreviewStyle =
true );
398 void removeComposerItem(
QgsComposerItem* item,
bool createCommand =
true );
411 void beginPrint( QPrinter& printer );
413 void beginPrintAsPDF( QPrinter& printer,
const QString&
file );
415 void doPrint( QPrinter& printer, QPainter& painter );
418 void print( QPrinter &printer );
421 void exportAsPDF(
const QString&
file );
425 QImage printPageAsRaster(
int page );
429 void renderPage( QPainter* p,
int page );
432 void computeWorldFileParameters(
double& a,
double& b,
double& c,
double& d,
double& e,
double& f )
const;
437 static void relativeResizeRect( QRectF& rectToResize,
const QRectF& boundsBefore,
const QRectF& boundsAfter );
439 static double relativePosition(
double position,
double beforeMin,
double beforeMax,
double afterMin,
double afterMax );
465 void createDefaultPageStyleSymbol();
521 QRectF compositionBounds()
const;
524 void updateZValues(
bool addUndoCommands =
true );
528 int boundingRectOfSelectedItems( QRectF& bRect );
537 QPointF minPointFromXml(
const QDomElement& elem )
const;
541 void updatePaperItems();
543 void removePaperItems();
544 void deleteAndRemoveMultiFrames();
546 static QString encodeStringForXML(
const QString& str );
551 void paperSizeChanged();
552 void nPagesChanged();
578 void statusMsgChanged( QString message );
584 QList<QGraphicsItem *> graphicsItemList = items();
585 QList<QGraphicsItem *>::iterator itemIt = graphicsItemList.begin();
586 for ( ; itemIt != graphicsItemList.end(); ++itemIt )
588 T* item =
dynamic_cast<T*
>( *itemIt );
591 itemList.push_back( item );