00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef QGSCOMPOSITION_H
00017 #define QGSCOMPOSITION_H
00018
00019 #include <QDomDocument>
00020 #include <QGraphicsScene>
00021 #include <QLinkedList>
00022
00023 class QgsComposerItem;
00024 class QgsComposerMap;
00025 class QgsPaperItem;
00026 class QGraphicsRectItem;
00027 class QgsMapRenderer;
00028
00029 class QDomElement;
00030
00037 class CORE_EXPORT QgsComposition: public QGraphicsScene
00038 {
00039 Q_OBJECT
00040 public:
00041
00043 enum PlotStyle
00044 {
00045 Preview = 0,
00046 Print,
00047 Postscript
00048 };
00049
00051 enum GridStyle
00052 {
00053 Solid,
00054 Dots,
00055 Crosses
00056 };
00057
00058 QgsComposition( QgsMapRenderer* mapRenderer );
00059 ~QgsComposition();
00060
00062 void setPaperSize( double width, double height );
00063
00065 double paperHeight() const;
00066
00068 double paperWidth() const;
00069
00070 void setSnapToGridEnabled( bool b );
00071 bool snapToGridEnabled() const {return mSnapToGrid;}
00072
00073 void setSnapGridResolution( double r );
00074 double snapGridResolution() const {return mSnapGridResolution;}
00075
00076 void setSnapGridOffsetX( double offset );
00077 double snapGridOffsetX() const {return mSnapGridOffsetX;}
00078
00079 void setSnapGridOffsetY( double offset );
00080 double snapGridOffsetY() const {return mSnapGridOffsetY;}
00081
00082 void setGridPen( const QPen& p );
00083 const QPen& gridPen() const {return mGridPen;}
00084
00085 void setGridStyle( GridStyle s );
00086 GridStyle gridStyle() const {return mGridStyle;}
00087
00089 QgsComposerItem* composerItemAt( const QPointF & position );
00090
00091 QList<QgsComposerItem*> selectedComposerItems();
00092
00094 QList<const QgsComposerMap*> composerMapItems() const;
00095
00098 const QgsComposerMap* getComposerMapById( int id ) const;
00099
00100 int printResolution() const {return mPrintResolution;}
00101 void setPrintResolution( int dpi ) {mPrintResolution = dpi;}
00102
00103 bool printAsRaster() const {return mPrintAsRaster;}
00104 void setPrintAsRaster( bool enabled );
00105
00107 QgsMapRenderer* mapRenderer() {return mMapRenderer;}
00108
00109 QgsComposition::PlotStyle plotStyle() const {return mPlotStyle;}
00110 void setPlotStyle( QgsComposition::PlotStyle style ) {mPlotStyle = style;}
00111
00115 int pixelFontSize( double pointSize ) const;
00116
00118 double pointFontSize( int pixelSize ) const;
00119
00121 bool writeXML( QDomElement& composerElem, QDomDocument& doc );
00122
00124 bool readXML( const QDomElement& compositionElem, const QDomDocument& doc );
00125
00127 void addItemToZList( QgsComposerItem* item );
00129 void removeItemFromZList( QgsComposerItem* item );
00130
00131
00132 void raiseSelectedItems();
00133 void raiseItem( QgsComposerItem* item );
00134 void lowerSelectedItems();
00135 void lowerItem( QgsComposerItem* item );
00136 void moveSelectedItemsToTop();
00137 void moveItemToTop( QgsComposerItem* item );
00138 void moveSelectedItemsToBottom();
00139 void moveItemToBottom( QgsComposerItem* item );
00140
00141
00142 void alignSelectedItemsLeft();
00143 void alignSelectedItemsHCenter();
00144 void alignSelectedItemsRight();
00145 void alignSelectedItemsTop();
00146 void alignSelectedItemsVCenter();
00147 void alignSelectedItemsBottom();
00148
00151 void sortZList();
00152
00154 QPointF snapPointToGrid( const QPointF& scenePoint ) const;
00155
00156
00157 private:
00159 QgsMapRenderer* mMapRenderer;
00160 QgsComposition::PlotStyle mPlotStyle;
00161 QgsPaperItem* mPaperItem;
00162
00164 QLinkedList<QgsComposerItem*> mItemZList;
00165
00167 int mPrintResolution;
00168
00170 bool mPrintAsRaster;
00171
00173 bool mSnapToGrid;
00174 double mSnapGridResolution;
00175 double mSnapGridOffsetX;
00176 double mSnapGridOffsetY;
00177 QPen mGridPen;
00178 GridStyle mGridStyle;
00179
00180 QgsComposition();
00181
00183 void updateZValues();
00184
00187 int boundingRectOfSelectedItems( QRectF& bRect );
00188
00189 void loadGridAppearanceSettings();
00190 void saveGridAppearanceSettings();
00191
00192 signals:
00193 void paperSizeChanged();
00194 };
00195
00196 #endif
00197
00198
00199